java - UtteranceProgressListener not working for Android TTS -
I am creating an app that uses TTS to synthesize wav files every time the broadcasting receiver starts is. I am working on Android studio (latest) and I am using API level 19 with 15 minutes.
"+" Tst.wav "); tts.synthesizeToFile (game, empty, storagepath + "/"
The file has been successfully created, but the ondown (method) of the mutation progress list is never called.
Creates on Public Zero () {super.onCreate (); If TTS TTS = New TextToSpeech (PresenterService.this, New TextToSpeech.OnInitListener) {@Override Public Zero onInit (integer position) {// if available, use TextToSpeech.Engine.ACTION_CHECK_TTS_DATA to check: // TODO TTS capabilities received // // TTS engine was successfully launched {tts.setLanguage (Locale.US); tts.setPitch (PRESENTER_PITCH); tts.setSpeechRate (PRESENTER_RATE);} (position = TextToSpeech.ERROR!)}}); Tts.setOnUtteranceProgressListener (new TtsUtteranceListener ()); IntentFilter Filter = New Intent Filter (); Filter.addAction ("xxxxxxxxxxxxxxxxxx"); MReceiver = New Trackchanger Records (TTS); Register receiver (MREC, filter); }
and the TtsUtteranceListener class:
Public class TtsUtteranceListener extends UtteranceProgressListener {@Override Public Zero onDone (string utteranceId) {Log.d ("TtsUtteranceListener", "Full of pronunciation:" + speaking id); } @ Override Public Wide Onstart (string wines id) {log d. ("TTSAterence Listener", "Warnance Start:" + Work ID); } @ Override Public Empty On Error (String Weapon ID) {Log D. ("TTSAttens LISTENER", "Dictation error:" + Work-indented); }}
Method on the listener:
Reaction on the public null (reference reference, intention intent) {string action = intent.getAction (); If (action! = Null) {if (action.equalsIgnoreCase ("xxxxxxxxxxxxxxxxx")) {string game = "test string"; Tts.synthesizeToFile (playing, empty, storagepath + "/" + "tst.wav"); I am using Android studio, and with debug mode I can see that the MUTearrence Progress of TTS Object Lestner has some object reference: Com.example.android.ttstest TtsUtteranceListener @ 41eaf8d8
But the listener's methods are never called. Log D () call never works and no breakpoints have ever triggered.
I also tried to declare the mutation progress listener as an unknown class when
tts.setOnUtteranceProgressListener (new mutation progressivity) {...} );
But the same thing ...
Does anyone tell me what I am doing?
OK, I solved it. String, string & gt; The problem is that I was unable to pass KEY_PARAM_UTTERANCE_ID
if (action.equalsIgnoreCase ("xxxxxxxxxxxxxxxxx")) {HashMap & lt; hashts = new hashmap & Lt; String, string & gt; (); HashTts.put (TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, "id"); String game = "test string"; Tts.synthesizeToFile (play, hashts, storagepath + "/" + "TST."); }
I was passing the parameter parameter nullly:
tts.synthesizeToFile (playing, blank, storagepath + "/" + "tst .wav ");
Comments
Post a Comment