Implement OnUtteranceCompletedListener
or UtteranceProgressListener
and call startListening
in onUtteranceCompleted
or onDone
How to stop voice recognition during tts speaking?
-
11-06-2023 - |
Frage
I am making an application that uses both voice recognition and tts. In my application I have continues voice recognition, the problem is that when I use tts the voice recognition will listen for what the app said. How can I stop the voice recognition during the time tts is speaking and then start it after the tts finishes? Can I solve the problem in another way?
Lösung
Andere Tipps
I could fix it with an Asynctask
But I can't launch the voice recognition now.
private class MiTareaAsincronaDialog extends AsyncTask<Void, Integer, Boolean> {
@Override
protected Boolean doInBackground(Void... params)
{
String words = "Esto es una prueba del texto pasado a oral";
speakWords(words);
while(myTTS.isSpeaking() == true)
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return true;
}
@Override
protected void onProgressUpdate(Integer... values) {
}
@Override
protected void onPreExecute() {
}
@Override
protected void onPostExecute(Boolean result) {
Toast.makeText(MainActivity.this, "Tarea finalizada!",
Toast.LENGTH_SHORT).show();
}
@Override
protected void onCancelled()
{
Toast.makeText(MainActivity.this, "Tarea cancelada!",
Toast.LENGTH_SHORT).show();
}
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow