暂停在TTS的android [英] Pause in TTS android

查看:1122
本文介绍了暂停在TTS的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,它会读出文档中的文本,我想添加一个暂停和恢复功能,但我找不到任何的TTS暂停()方法。有没有什么办法,我可以暂停..?

I'm developing an app which would read out the text in the document and I want to add a pause and resume functionality but I can't find any pause() method in TTS. Is there any way that I can pause..?

推荐答案

有一个办法暂停。只需拨打 TextToSpeech.playSilence()看到<一低于code href="https://github.com/gast-lib/gast-lib/blob/master/app/src/root/gast/playground/speech/tts/TextToSpeechDemo.java"相对=nofollow>这里。

There is a way to pause. Just call TextToSpeech.playSilence() see the code below from here.

据讲一些实际的文本以及一些沉默。

It speaks some actual text along with some silence.

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);

}

这篇关于暂停在TTS的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆