Android Question ExoPlayer cannot automatically play wav files generated by tts

watesoft

Active Member
Licensed User
Longtime User
Because the tts engine lacks pause and resume functions, I want to generate a wav file and play it with ExoPlayer.
The text is a bit long and the wav generation speed is a bit slow, I use the wait for method to wait for the end, but ExoPlayer cannot automatically play the wav file.
I need a way to wait for the end of the wav file generation, preferably with an end prompt, the next step is to automatically or manually play the wav file safely.
Thank you in advance!
 

Attachments

  • TTS To WAV.zip
    11.4 KB · Views: 108

JohnC

Expert
Licensed User
Longtime User
Try this code:

B4X:
    Dim jo As JavaObject = tts1
    Dim m As JavaObject
    m.InitializeNewInstance("java.util.HashMap", Null)
    jo.RunMethod("synthesizeToFile", Array(txtTTS.text, m, File.Combine(File.DirRootExternal, "1.wav")))
   
    Sleep(1000)   'wait a little for the TTS to start so the below loop will properly "see" that it is talking
   
    Do While jo.RunMethod("isSpeaking",Null) = True
        Sleep(100)
    Loop
    Log("done speaking")
   
    PlayTTS 'routine to play file
 
Last edited:
Upvote 0

watesoft

Active Member
Licensed User
Longtime User
Try this code:

B4X:
    Dim jo As JavaObject = tts1
    Dim m As JavaObject
    m.InitializeNewInstance("java.util.HashMap", Null)
    jo.RunMethod("synthesizeToFile", Array(txtTTS.text, m, File.Combine(File.DirRootExternal, "1.wav")))
   
    Sleep(1000)
   
    Do While jo.RunMethod("isSpeaking",Null) = True
        Sleep(100)
    Loop
    Log("done speaking")
   
    PlayTTS 'routine to play file
Thank you very much, it is exactly what I need, it works very well
 
Upvote 0
Top