【问题标题】:Voice Recognition: gap between words语音识别:单词之间的差距
【发布时间】:2016-02-01 20:54:35
【问题描述】:

我有一个简单的语音识别应用程序,它打印所有可能的字符串 ArrayList 解码。问题是它只有在我不在单词之间停止/暂停时才有效。如果我有一个轻微的停顿(非常短,就像我正常说话一样),应用程序就会停止。我查看了参数 SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS 但它没有改变任何东西。

语音识别专家有什么线索吗?

这是我的代码:

package com.bernard.vtt;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.speech.RecognitionListener;
import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import java.util.ArrayList;

public class MainActivity extends Activity implements RecognitionListener {
    private TextView mText;
    SpeechRecognizer speech = null;
    private Intent recognizerIntent;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button speakButton = (Button) findViewById(R.id.btn);
    mText = (TextView) findViewById(R.id.textView1);

    speech = SpeechRecognizer.createSpeechRecognizer(this);
    speech.setRecognitionListener(this);
    recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE,
            "en");
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
            this.getPackageName());
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);

    speakButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            speech.startListening(recognizerIntent);
        }
    });

}

@Override
public void onResults(Bundle results) {
    ArrayList<String> matches = results
            .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    String text = "";
    assert matches != null;
    for (String result : matches)
        text += result + "\n";

    mText.setText(text);

    speech.stopListening();
}

@Override
public void onReadyForSpeech(Bundle params) {

}

@Override
public void onBeginningOfSpeech() {

}

@Override
public void onRmsChanged(float rmsdB) {

}

@Override
public void onBufferReceived(byte[] buffer) {

}

@Override
public void onEndOfSpeech() {

}

@Override
public void onError(int error) {

}

@Override
public void onPartialResults(Bundle partialResults) {

}

@Override
public void onEvent(int eventType, Bundle params) {

}

【问题讨论】:

标签: android voice-recognition


【解决方案1】:

我相信内置语音识别不会持续运行。它旨在听到一个语音输入并给出结果。如果您想持续收听,您需要在每个 onResults 回调上重新开始识别。我也相信SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS 有一个最大值,这就是为什么改变它没有什么效果。

【讨论】:

  • 我怀疑它是这样设计的,因为我使用 startactivity 方法实现了相同的测试并且得到了相同的结果。我明天会尝试,但我觉得这样做是一种解决方法。我希望看到对我的问题的更多回应。
  • @narb 直接来自Google's documentaion:“此API 的实现很可能会将音频流式传输到远程服务器以执行语音识别。因此,此API 不打算用于连续识别,这会消耗大量电池和带宽。”
  • @narb 要进一步扩展,要在 Android 上执行持续识别,您可能需要使用 Nuance 等第三方产品。我们试图破坏 SpeechRecognizer 以执行您在此处寻找的连续识别,但最终不得不与第三方合作。您也可以根据需要考虑CMUSphinx
  • 谢谢!我去看看:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多