在 Android 应用程序中使用文本转语音 API

发布于 2024-12-19 10:19:46 字数 129 浏览 0 评论 0原文

我想在我的 Android 应用程序中使用 TTS(文本到语音)API。现在我有一个问题 - 它支持土耳其语吗? 我还想在说出特定单词时在文本视图中突出显示该单词。

我该怎么做? 有人可以帮助我吗?

提前致谢 !

I want to use TTS (Text to Speech) APIs in my android application.Now i have one quetions - Is it support TURKISH language ?
I also want to highlight word in textview when that perticular word is being spoke.

How can i do it ?
Can anybody help me ?

Thanks in advance !

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

余厌 2024-12-26 10:19:46

是否支持土耳其语

这可能因不同的手机/Android 风格而异。您可以使用以下命令自行检查

   mTTS.isLanguageAvailable(new Locale("tr", "TUR"));

我还想在说出特定单词时在文本视图中突出显示该单词。

好吧,你有一个 TextToSpeech.OnUtteranceCompletedListener(),使用这个你必须speak()每个单词,一次一个。

Does it support TURKISH language

This may vary on different handsets/flavours of Android. You can check it out for yourself using the

   mTTS.isLanguageAvailable(new Locale("tr", "TUR"));

I also want to highlight word in textview when that particular word is being spoke.

Well you have a TextToSpeech.OnUtteranceCompletedListener(), to use this you have to speak() each word, one at a time.

水溶 2024-12-26 10:19:46

Android 平台附带的 TTS 引擎支持多种语言:英语、法语、德语、意大利语和西班牙语。此外,根据您位于大西洋的哪一边,美国和英国英语口音都受支持。

http://developer.android.com/resources/articles/tts.html

The TTS engine that ships with the Android platform supports a number of languages: English, French, German, Italian and Spanish. Also, depending on which side of the Atlantic you are on, American and British accents for English are both supported.

http://developer.android.com/resources/articles/tts.html

梦里的微风 2024-12-26 10:19:46

您应该使用 Locale 类型变量。

 Final Locale locale = new Locale("tr", "TR");          

  tts = new TextToSpeech(getApplicationContext(), new
  TextToSpeech.OnInitListener() {
        @覆盖
        公共无效onInit(int状态){

             如果(状态== TextToSpeech.SUCCESS){
                int 结果 = tts.setLanguage(locale);
                如果(结果== TextToSpeech.LANG_MISSING_DATA
                        ||结果== TextToSpeech.LANG_NOT_SUPPORTED) {
                    Log.d("类名","tts错误");
                }
            } 别的 {
                Log.d("类名","tts错误");
            }
        }
    });
   tts.speak("用土耳其语写下您想要的内容", TextToSpeech.QUEUE_FLUSH, null);

You should use Locale type variable.

  final Locale locale = new Locale("tr", "TR");          

  tts = new TextToSpeech(getApplicationContext(), new
  TextToSpeech.OnInitListener() {
        @Override
        public void onInit(int status) {

             if (status == TextToSpeech.SUCCESS) {
                int result = tts.setLanguage(locale);
                if (result == TextToSpeech.LANG_MISSING_DATA
                        || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                    Log.d("class name", "tts error ");
                }
            } else {
                Log.d("class name", "tts error ");
            }
        }
    });
   tts.speak("write here what you want in Turkish", TextToSpeech.QUEUE_FLUSH, null);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文