我在StackOverFlow上搜索了很多这个问题,但线程已超过3年了。
我实施了需要互联网连接的Google Voice Recognition
。搜索我如何使用Offline Voice Recognition
没有带来任何成功。
现在可以在您离线时使用Voice Recognition
吗?
直到我的代码:
speechStartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
promtSpeechInput();
}
});
private void promtSpeechInput() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
"Recording...");
try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT);
} catch (ActivityNotFoundException e) {
Toast.makeText(getApplicationContext(), "Language not supported", Toast.LENGTH_SHORT).show();
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case CAMERA_PIC_REQUEST: {
try {
Bitmap image = (Bitmap) data.getExtras().get("data");
ImageView imageView = (ImageView) findViewById(R.id.taskPhotoImage);
imageView.setImageBitmap(image);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
case REQ_CODE_SPEECH_INPUT: {
if(resultCode == RESULT_OK && null != data) {
ArrayList<String> result = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
speechToTextField.setText(speechToTextField.getText()+" " +result.get(0));
}
break;
}
}
}
King Regards
答案 0 :(得分:5)
不是谷歌。
您必须使用其他解决方案,例如CMU Sphinx。 点击此处:Android: Speech Recognition without using google server
答案 1 :(得分:0)
实际上,您可以按照here所述离线使用SpeechRecognizer。
这个问题是没有使用循环就不连续,并且使用带有SpeechRecognizer的循环由于持续的哔哔声而非常烦人。哔哔声有很多方法,但大多数都会将哔哔声和所有音频流静音。
步骤中还提到,您还必须下载“Google Voice Typing”及其语言,从而占用更多存储空间。总的来说,你可以离线使用SpeechRecognizer,但这是一个很大的麻烦。