语音识别:单词之间的差距
Voice Recognition: gap between words
我有一个简单的语音识别应用程序,可以打印所有可能的字符串 ArrayList 解码。问题是它只有在我不 stop/pause 单词之间时才有效。如果我有轻微的停顿(很短,就像我正常说话一样),应用程序会停止。我查看了参数 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) {
}
我相信内置语音识别不会持续 运行。它旨在听到一个语音输入并给出结果。如果您想持续收听,则需要在每个 onResults 回调上重新启动识别。我也相信 SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS
有一个最大值,这就是为什么改变它几乎没有效果。
我有一个简单的语音识别应用程序,可以打印所有可能的字符串 ArrayList 解码。问题是它只有在我不 stop/pause 单词之间时才有效。如果我有轻微的停顿(很短,就像我正常说话一样),应用程序会停止。我查看了参数 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) {
}
我相信内置语音识别不会持续 运行。它旨在听到一个语音输入并给出结果。如果您想持续收听,则需要在每个 onResults 回调上重新启动识别。我也相信 SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS
有一个最大值,这就是为什么改变它几乎没有效果。