benjaminwan/ChineseTtsTflite

运行时这个错误,请问怎么解决?

lrf1027430 opened this issue · 4 comments

2022-12-30 16:20:01.680 10684-10684/com.benjaminwan.chinesettstflite E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.benjaminwan.chinesettstflite, PID: 10684
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.benjaminwan.chinesettstflite/com.benjaminwan.chinesettstflite.ui.MainActivity}: java.lang.IllegalArgumentException: Contents of /data/user/0/com.benjaminwan.chinesettstflite/files/fastspeech2_quan.tflite does not encode a valid TensorFlow Lite model: Mmap of '60' at offset '0' failed with error '22'.
The model allocation is null/empty
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalArgumentException: Contents of /data/user/0/com.benjaminwan.chinesettstflite/files/fastspeech2_quan.tflite does not encode a valid TensorFlow Lite model: Mmap of '60' at offset '0' failed with error '22'.
The model allocation is null/empty
at org.tensorflow.lite.NativeInterpreterWrapper.createModel(Native Method)
at org.tensorflow.lite.NativeInterpreterWrapper.(NativeInterpreterWrapper.java:50)
at org.tensorflow.lite.NativeInterpreterWrapperExperimental.(NativeInterpreterWrapperExperimental.java:40)
at org.tensorflow.lite.Interpreter.(Interpreter.java:196)
at com.benjaminwan.chinesettstflite.tts.FastSpeech2.(FastSpeech2.kt:12)
at com.benjaminwan.chinesettstflite.tts.TtsManager.initModels(TtsManager.kt:86)
at com.benjaminwan.chinesettstflite.ui.MainActivity.onCreate(MainActivity.kt:25)
at android.app.Activity.performCreate(Activity.java:7224)
at android.app.Activity.performCreate(Activity.java:7213)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
... 11 more

log提示模型加载错误:fastspeech2_quan.tflite does not encode a valid TensorFlow Lite model: Mmap of '60' at offset '0' failed with error '22'。
这个项目只是个调用范例,模型的问题需要去问模型作者,这方面的问题我不清楚。

image
请问你那里还有可以用的模型吗?我是到图片中的链接中去下载的。

如果是这里下载的模型,应该是没问题的,许多人都用过了。
你可以直接下载ChineseTtsTflite-0.5.0-release.apk,运行起来看是不是正常。
https://github.com/benjaminwan/ChineseTtsTflite/releases/tag/0.5.0
如果这个apk是正常的,可以把apk扩展名改为zip,用压缩软件打开,里面的assets里就是模型文件。

可以运行,感谢。