2012-06-17 13 views
6

Sto sviluppando un'app che dovrebbe leggere il testo nel documento e voglio aggiungere una pausa e riprendere la funzionalità ma non riesco a trovare alcun metodo pause() in TTS. C'è un modo in cui posso mettere in pausa ..?Pausa in TTS android

risposta

5

C'è un modo per mettere in pausa. Basta chiamare il numero TextToSpeech.playSilence() per vedere il codice sottostante da here.

Parla un testo vero e un po 'di silenzio.

private void playScript() 
{ 
    Log.d(TAG, "started script"); 
// setup 

// id to send back when saying the last phrase 
// so the app can re-enable the "speak" button 
HashMap<String, String> lastSpokenWord = new HashMap<String, String>(); 
lastSpokenWord.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, 
     LAST_SPOKEN); 

// add earcon 
final String EARCON_NAME = "[tone]"; 
tts.addEarcon(EARCON_NAME, "root.gast.playground", R.raw.tone); 

// add prerecorded speech 
final String CLOSING = "[Thank you]"; 
tts.addSpeech(CLOSING, "root.gast.playground", 
     R.raw.enjoytestapplication); 

// pass in null to most of these because we do not want a callback to 
// onDone 
tts.playEarcon(EARCON_NAME, TextToSpeech.QUEUE_ADD, null); 
tts.playSilence(1000, TextToSpeech.QUEUE_ADD, null); 
tts.speak("Attention readers: Use the try button to experiment with" 
     + " Text to Speech. Use the diagnostics button to see " 
     + "detailed Text to Speech engine information.", 
     TextToSpeech.QUEUE_ADD, null); 
tts.playSilence(500, TextToSpeech.QUEUE_ADD, null); 
tts.speak(CLOSING, TextToSpeech.QUEUE_ADD, lastSpokenWord); 

}

Problemi correlati