TensorSpeech / TensorFlowTTS

:stuck_out_tongue_closed_eyes: TensorFlowTTS: Real-Time State-of-the-art Speech Synthesis for Tensorflow 2 (supported including English, French, Korean, Chinese, German and Easy to adapt for other languages)
https://tensorspeech.github.io/TensorFlowTTS/
Apache License 2.0
3.82k stars 812 forks source link

Android using tf_nightly 2.6.0.dev20210426 #553

Closed Zak-SA closed 3 years ago

Zak-SA commented 3 years ago

Hi, any help to use tf-nightly 2.6.0.dev20210426 or even 2.5.0 converting Fastspeech2 in android? what changes we should apply? I tried the existing android code and it didn;t work, only if I use tf-nightly 2.4.0.dev202002301 but this version can not be found anymore and will stop working on July 2021. mbmelgan worked fine using the new version of tf-nightly but not fastspeech2

Thanks

Zak-SA commented 3 years ago

just a clarification to my question, the conversion works fine and I can inference using the TFlite model from python, but my question is about the necessary changes for Android code including gradle.build or fastspeech2.java or any other changes to android. Thanks

Zak-SA commented 3 years ago

@dathudeptrai I need your help good old friend

dathudeptrai commented 3 years ago

@Zak-SA did you try tflite nightly in android ?

Zak-SA commented 3 years ago

@dathudeptrai yes, I already have the fastspeech2 tflite working on android but only when converted using tf-nighlty version 2.4.0and not the new versions, tf-nightly 2.4.0 is no longer available or supported , so I was wondering what changes should apply on the android example to make it work with the new tf-nightly. Thanks

Zak-SA commented 3 years ago

@dathudeptrai another note, the android works if the runtime used for conversion is 1.14.0 and didn't work when I used runtime 2.3.0

dathudeptrai commented 3 years ago

@Zak-SA I do not know but you just need to change the version of tflite in the android example and it's enough. If it doesn't work, there should be a bug in tflite-nightly then you need ask tflite authors for this bug :D.

Zak-SA commented 3 years ago

@dathudeptrai do you mean in app build gradle dependencies? as far as I know that in android you just chose 0.0.0 and you can't pin specific version but android get updates everyday. in android/app/build.gradle from line 36 to 38

https://github.com/TensorSpeech/TensorFlowTTS/blob/ba46b472f99b09bbdfc6b9261626c10fb2f2be14/examples/android/app/build.gradle

implementation 'org.tensorflow:tensorflow-lite:0.0.0-nightly' implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly' implementation 'org.tensorflow:tensorflow-lite-support:0.0.0-nightly'

maybe it's something related to input and output? I'll try different version of tfnightly and see if it works.

dathudeptrai commented 3 years ago

@Zak-SA can you follow (https://www.tensorflow.org/lite/guide/android#use_the_tensorflow_lite_aar_from_jcenter). use org.tensorflow:tensorflow-lite-support:0.1.0 and org.tensorflow:tensorflow-lite:0.0.0-nightly-SNAPSHOT and org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly-SNAPSHOT

Zak-SA commented 3 years ago

@dathudeptrai I will try and let you know, I didn't change what in the example because it worked before

Zak-SA commented 3 years ago

@dathudeptrai I changed the dependencies and still crashes, I get java.lang.NullPointerException: Attempt to invoke virtual method 'void org.tensorflow.lite.Interpreter.resizeInput(int, int[])' on a null object reference

the only difference between the working tflite model and the one causing the error I am getting is the tf-nightly and runtime used for conversion, the new tf-nightly uses 2.3.0 while the one works uses 1.14.0

Urteilsbilder commented 3 years ago

@Zak-SA I get the same error: Attempt to invoke virtual method 'void org.tensorflow.lite.Interpreter.resizeInput(int, int[])' on a null object reference

But the error is a consequence of this error: W/System.err: java.lang.IllegalArgumentException: Contents of /data/user/0/com.tensorspeech.tensorflowtts/files/fastspeech2_quant.tflite does not encode a valid TensorFlow Lite model: Mmap of '/data/user/0/com.tensorspeech.tensorflowtts/files/fastspeech2_quant.tflite' failed. The model is not a valid Flatbuffer file at org.tensorflow.lite.NativeInterpreterWrapper.createModel(Native Method) W/System.err: at org.tensorflow.lite.NativeInterpreterWrapper.(NativeInterpreterWrapper.java:47) W/System.err: at org.tensorflow.lite.Interpreter.(Interpreter.java:207) at com.tensorspeech.tensorflowtts.module.FastSpeech2.(FastSpeech2.java:28) at com.tensorspeech.tensorflowtts.tts.InputWorker.(InputWorker.java:31) at com.tensorspeech.tensorflowtts.tts.TtsManager.lambda$init$0$TtsManager(TtsManager.java:46) at com.tensorspeech.tensorflowtts.tts.-$$Lambda$TtsManager$R0nEkwbjUVH2mDm7AjctdARtIkA.run(Unknown Source:4) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)

I didn't change anything on the project and just imported it. It worked for me a few months ago, now it doesnt.

Zak-SA commented 3 years ago

@Urteilsbilder what version of tensorflow did you use to convert the model to tflite? Also I beleive that tensorflow dependencies migrated from jcenter and will no longer be updated from there.

Urteilsbilder commented 3 years ago

@Zak-SA I did not convert anything, already with the Tflite models that came with the project the errors came.

Zak-SA commented 3 years ago

@Urteilsbilder that's weird, if I use tf-nightly 2.4.0 to convert the models it works fine. Only when I use newer version of tensorflow I get this issue .

Urteilsbilder commented 3 years ago

On some devices it works and on others I get this error: A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xfffffff4 in tid 6679 (init-21), pid 6654 (h.tensorflowtts)

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.