に気付くことはありません。私のデバイスはVuzix M300で、私は音声コントロールを動作させようとしています。 私の問題は、私は私のSpeechRecognizerを初期化し、startListiningメソッドを呼び出すと、すべてが実行されることで、何の音声が認識されないことを期待しています。私はAndroidの携帯電話で同じコードを試してみましたが、うまく機能しました。アンドロイドSpeechRecognizerは私のAndroidアプリの機知の問題をhabeマイク入力
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//grant access to internet
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//set layout
setContentView(R.layout.activity_main);
speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication().getPackageName());
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "de-DE");
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, false);
speechRecognizer.setRecognitionListener(prepareRegnitionListener());
speechRecognizer.startListening(speechRecognizerIntent);
//startListening(0);
}
private RecognitionListener prepareRegnitionListener() {
// TODO Auto-generated method stub
return new RecognitionListener() {
@Override
public void onRmsChanged(float rmsdB) {
//Didn´t use
}
@Override
public void onResults(Bundle results) {
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
Log.d(MainActivity,"Completed speech recognition: Result: " + matches);
String match = matches.get(0);
}
@Override
public void onReadyForSpeech(Bundle params) {
Log.d(MainActivity, "ReadyforSpeech");
}
@Override
public void onPartialResults(Bundle partialResults) {
// Nothing
ArrayList<String> matches = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
Log.d(MainActivity,"Completed speech recognition: Result: " + matches);
}
@Override
public void onEvent(int eventType, Bundle params) {
// Nothing
}
@Override
public void onError(int error) {
switch (error){
case SpeechRecognizer.ERROR_AUDIO:
Log.e(MainActivity,"Failed to recognize speech: Audio recording error.");
startListening(1000);
break;
case SpeechRecognizer.ERROR_CLIENT:
Log.e(MainActivity,"Failed to recognize speech: Insufficient permissions.");
startListening(1000);
break;
case SpeechRecognizer.ERROR_NO_MATCH:
Log.d(MainActivity,"Failed to recognize speech: No recognition results matched. Retrying...");
startListening(1000);
break;
default:
Log.e(MainActivity,"Failed to recognize speech. Unknown error" + error);
startListening(1000);
}
}
@Override
public void onEndOfSpeech() {
Log.d(MainActivity, "EndofSpeech");
}
@Override
public void onBufferReceived(byte[] buffer) {
//Didn´t use
}
@Override
public void onBeginningOfSpeech() {
Log.d(MainActivity, "beginnofSpeech");//Do something when speaking starts
}
};
}
private void startListening(int delay){
if(delay > 0){
Timer t = new Timer();
t.schedule(new TimerTask(){
@Override
public void run() {
mainHandler.post(new Runnable() {
@Override
public void run() {
speechRecognizer.startListening(speechRecognizerIntent);
Log.d(MainActivity,"Start delayed listening to speech");
speechRecognizer.stopListening();
}
});
}}
, delay);
}else{
speechRecognizer.startListening(speechRecognizerIntent);
Log.d(MainActivity,"Start instant listening to speech.");
}
}
私はAndroidの6およびビュージックスのファームウェア1.2(最新版)でビュージックスを実行しています:
は、ここに私のコードです。
は、私は私がなるだろうようには音声入力が指定されていない場合は、(私は与える)エラーコードERROR_SPEECH_TIMEOUTを取得します。
は、私はすでに
DroidSpeechを試してみてください。これはすべての重労働を処理し、実装が非常に簡単です - https://github.com/vikramezhil/DroidSpeech –