【问题标题】:EXTRA_LANGUAGE_PREFERENCE for SpeechRecognizer?SpeechRecognizer 的 EXTRA_LANGUAGE_PREFERENCE?
【发布时间】:2012-06-05 16:35:07
【问题描述】:

this answer 中所述,为 RecognizerIntent 强制使用特定语言很简单。

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

但这只有在 intent 实例化的类型为 RecognizerIntent 时才有效。

在我的应用程序中,我使用较低级别的SpeechRecognizer,即:

  Intent intent = new Intent(SpeechRecognizer.RESULTS_RECOGNITION);

并且试图强制使用上述语言是行不通的。

以编程方式为SpeechRecognizer 设置语言首选项的正确方法是什么?

这可能吗?

【问题讨论】:

    标签: android speech-recognition


    【解决方案1】:

    语言偏好应该有效。

    请发布更多代码。

    您仍然应该像这样创建Intent

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    

    不是这样的:

     Intent intent = new Intent(SpeechRecognizer.RESULTS_RECOGNITION);
    

    然后你必须直接调用SpeechRecognizer 类。

    你在做吗?

    有关参考,请参阅此coderecognizeSpeechDirectly() 方法。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-05
      • 1970-01-01
      • 1970-01-01
      • 2018-07-12
      • 2014-08-25
      相关资源
      最近更新 更多