音频输入和输出(Android代码)
如何更改我的 Android 代码中的音频输入和输出语言?我应该编辑此代码来更改音频输入输出语言吗? {如果可能的话,我想将一个变量设置为 En 以选择英语语音,或者将变量设置为 Tr 以选择土耳其语?}
public Intent getRecognizeIntent()
{
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);
return intent;
}
或者这可以帮助我更改? -> EXTRA_LANGUAGE_PREFERENCE
How i change audio input and output language in my android code? Should i edit this code to change audio input output language ? {I want to set one variable to En to speech language English or set variable to Tr to select Turkish if this possible?}
public Intent getRecognizeIntent()
{
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);
return intent;
}
Or this help me to change? -> EXTRA_LANGUAGE_PREFERENCE
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我将 RecognizerIntent 语言设置为土耳其语,如下所示:
I set RecognizerIntent language to Turkish like that:
这应该在大多数情况下有效:
或者
在您选择所需的区域设置并将其传递给 EXTRA_LANGUAGE_PREFERENCE 的 toString() 的地方
但是,为了正确起见,您应该尝试进行语言检查,并观察返回的“声音”。手动或自动选择所需的“语音”字符串,然后将其用作 RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE 值。
下面是一些执行语言检查的代码:
其中 LanguageDetailsChecker 是这样的:
This should work in most cases:
or
Where you pick the locale you want and pass it's toString() to EXTRA_LANGUAGE_PREFERENCE
However, to be correct, you should try doing a language check, and observing the returned "voices". Manually or automatically, pick the "voice" string you want and then use that for the RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE value.
Here is some code to execute the language check:
where LanguageDetailsChecker is something like this:
如果要指定语言识别,则需要输入:
其中
language
是具有区域设置格式的字符串。If you want to specify a language recognition you need to put:
where
language
is a String with the Locale format.