Dan*_*nko 15 python android ios dart flutter
我正在尝试开发用于音频指纹处理的 Flutter 应用程序。我正在使用Starflut进行 python 集成。这是一个简单的例子:
//python file for using from dart
def tt(a,b) :
print (a, b)
return 666,777
g1 = 123
def yy(a,b,z) :
print(a,b,z)
return {'jack': 4098, 'sape': 4139}
class Multiply :
def __init__(self):
pass
def multiply(self, a,b):
print("multiply....",a,b)
return a * b
Run Code Online (Sandbox Code Playgroud)
//dart code which uses python
void _initStarCore() async {
StarCoreFactory starcore = await Starflut.getFactory();
StarServiceClass service = await starcore.initSimple("test", "123", 0, 0, []);
srvGroup = await service["_ServiceGroup"];
bool isAndroid = await Starflut.isAndroid();
if (isAndroid == true) {
String libraryDir = await Starflut.getNativeLibraryDir();
String docPath = await Starflut.getDocumentPath();
if (libraryDir.indexOf("arm64") > 0) {
Starflut.unzipFromAssets("lib-dynload-arm64.zip", docPath, true);
} else if (libraryDir.indexOf("x86_64") > 0) {
Starflut.unzipFromAssets("lib-dynload-x86_64.zip", docPath, true);
} else if (libraryDir.indexOf("arm") > 0) {
Starflut.unzipFromAssets("lib-dynload-armeabi.zip", docPath, true);
} else {
Starflut.unzipFromAssets("lib-dynload-x86.zip", docPath, true);
}
await Starflut.copyFileFromAssets("python3.6.zip",
"flutter_assets/starfiles", null);
}
await srvGroup.initRaw("python36", service);
String resPath = await Starflut.getResourcePath();
srvGroup.loadRawModule("python", "",
resPath + "/flutter_assets/starfiles/" + "testpy.py", false);
dynamic python = await service.importRawContext("python", "", false, "");
StarObjectClass retobj = await python.call("tt", ["hello ", "world"]);
print(await retobj[0]);
print(await retobj[1]);
print(await python["g1"]);
StarObjectClass yy = await python.call("yy", ["hello ", "world", 123]);
print(await yy.call("__len__",[]));
StarObjectClass multiply = await service.importRawContext("python", "Multiply", true, "");
StarObjectClass multiply_inst = await multiply.newObject(["", "", 33, 44]);
print(await multiply_inst.getString());
print(await multiply_inst.call("multiply", [11, 22]));
await srvGroup.clearService();
await starcore.moduleExit();
}
Run Code Online (Sandbox Code Playgroud)
现在我需要导入 python 库Dejavu进行音频指纹识别,但我不知道该怎么做。在他们的存储库中的 starflut 文档或问题中没有任何关于它的内容。
有人遇到过同样的问题吗?或者也许有人对我如何尝试解决它有任何建议?
抱歉有错误,希望文字可以理解:) 英语不是我的母语。
如果没有,请尝试以下操作:
在命令提示符中:
pip install PyDejavu
Run Code Online (Sandbox Code Playgroud)
在需要导入 Dejavu 的模块中:
from dejavu import Dejavu
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3595 次 |
| 最近记录: |