(Android) 如何将语音识别语言设置为我选择的语言?

发布于 2024-12-29 08:32:32 字数 414 浏览 3 评论 0原文

如何将语音识别语言设置为我选择的语言?

例如,我可以设置更改语音识别语言吗?

我正在使用以下代码,但我不知道如何指定语言。

我能做些什么?

 Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
 RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
 intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
 intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100);

How do I set the voice recognition language to something that I choose?

For example, is there something that I can set to change the voice recognition language?

I am using the following code, but I do not know how to specify the language.

What can I do?

 Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
 intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
 RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
 intent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
 intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 100);

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

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

发布评论

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

评论(1

离鸿 2025-01-05 08:32:32

我以前从未使用过 RecognizerIntent。但似乎有一个额外的选项可以用来选择不同的语言

http://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_LANGUAGE

我认为如果你再进行一次 putExtra() 调用并传递它常量和正确形式的字符串(“en-US”)它将设置语言。

但是我不知道也没有在任何地方看到到底支持多少种/哪些语言。因此,尝试让它使用不同的语言可能会取得有限的成功。

我认为这样的事情就可以解决问题:

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");

您只需要找到您感兴趣的语言的 bcp47 兼容语言标签。

I've never used the RecognizerIntent before. But it seems like there is an extra that you can put for selecting a different language

http://developer.android.com/reference/android/speech/RecognizerIntent.html#EXTRA_LANGUAGE

I would think that if you make another putExtra() call and pass it that constant and a string in the proper form ("en-US") it would set the language.

However I don't know and don't see anywhere on there exactly how many / which languages are supported. So you may have limited success trying to have it use different languages.

I would think something like this would do the trick:

intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US");

you just need to find the bcp47 compliant language tag for the language you are interested in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文