TTS-UtteranceProgressListener not being called

前端 未结 4 1366
再見小時候
再見小時候 2020-12-17 07:43

I don\'t want to put all my code here, so I\'m just putting the relevant pieces. If you need more, feel free to ask.

I\'m using Text To Speech (TTS) which leads t

4条回答
  •  误落风尘
    2020-12-17 08:12

    found the answer...

    Turns out that the TTS resources I found online were using a single TTS string source, so the third parameter in tts.speak(String text, int queueMode, HashMap params) was set to null.

    to anybody having this issue in the future:

    if you set the third param to null, there's no ID for the UtteranceProgressListener to track. The fix was creating and initializing a hashmap, then adding to the included array for each new TTS with a new ID could be tracked. Here's the code:

    HashMap map = new HashMap();
    

    then, before calling tts.speak...

    map.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "UniqueID");
    

    then you can call speak with all params...

    tts.speak(text, TextToSpeech.QUEUE_FLUSH, map);
    

提交回复
热议问题