Play an audio file as soon as Text To Speech is co

2019-05-03 23:30发布

问题:

I'm trying to develop an Android app where as soon as the text to speech is completed an audio file has to be played. How to do this?

回答1:

If I didn't get wrong idea, you want to use text-to-speech to read some text and store the speech audio into phone in the meantime? And play the audio later?

Have you checked AudioRecordTest? You can record audio and then play it later. Worth to try but I don't think you can get a good quality from the microphone. Hope this helps:)

By the way, as far as I know, android only support to record from mic for unrooted phone, which you can check here. Let me know if you can record sound source from the android system.



回答2:

I have found the solution and that is in the method onUtteranceCompletedListener() we can know whether the speech is stopped or not and then we can write the code to play the audio file