2013-05-24 2 views
0

Android 음성 인식 엔진을 지속적으로 실행할 수있는 서비스를 만들려고합니다. Android Speech Recognition as a service on Android 4.1 & 4.2에서 예제를 보았습니다.하지만 어떻게 든 저는 말한 것과 관계없이 리스너 onError() 메서드에서 항상 SpeechRecognizer.ERROR_NO_MATCH 오류가 발생합니다. 물론 onResults()는 호출되지 않습니다. 위에 링크 된 질문에 대해 답 보였다으로 서비스의 코드는 정확하게, 그것을 시작하는 내 코드는 다음과 같습니다지속적인 음성 인식을위한 Android 서비스 만들기

Intent startServiceIntent = null;   
Log.d(TAG, "Creating new intent for the recognition service"); 
startServiceIntent = new Intent(getApplicationContext(), SpeechRecognitionService.class); 
Log.d(TAG, "Starting the speech recognition service ..."); 
getApplicationContext().startService(startServiceIntent); 

int duration = Toast.LENGTH_LONG; 
CharSequence text = "Starting speech recognition ..."; 
Toast toast = Toast.makeText(getApplicationContext(), text, duration); 
toast.show(); 

을하지만 직접 의도를 전송하여 음성 인식 엔진을 호출 할 때, 그것은 잘 작동 :

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 
        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Start talking"); 
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10); 
startActivityForResult(intent, 1234); 

내 모든 테스트는 Android 4.1.2와 함께 Note2에서 실행 중입니다. 누구든지이 문제에 직면했으며이를 해결하는 방법을 알고있을 수 있습니까? 감사합니다.

+0

예를 들어 hello와 같은 간단한 단어를 말하고 여전히 오류가 있는지 확인하십시오. –

+1

실전에서 풀 타임으로 나가려면 배터리 수명이 오래 걸리지 않을 것입니다. :) – adamp

+0

나는 "안녕하세요"라고 말하려고했고 같은 결과를 얻었습니다 ... 오디오의 음소거를 주석 처리했을 때 시스템이 인식을 시작할 때 나는 어떤 소리도들을 수 없었습니다. 그리고 물론 아무것도 내 화면에 표시되지 않았습니다. – Vadim

답변

0

EXTRA_CALLING_PACKAGE를 설정해보십시오. 그것은 의미가 없지만 그것이 당신의 문제를 해결할 것이라고 믿습니다. 아래의 방법을 참조하십시오. 또한 여기에서 코드를 확인하십시오 : https://github.com/gast-lib/gast-lib/blob/master/library/src/root/gast/speech/SpeechRecognizingActivity.java

public void recognizeDirectly(Intent recognizerIntent) 
    { 
     // SpeechRecognizer requires EXTRA_CALLING_PACKAGE, so add if it's not 
     // here 
     if (!recognizerIntent.hasExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE)) 
     { 
      recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, 
        "com.dummy"); 
     } 
     SpeechRecognizer recognizer = getSpeechRecognizer(); 
     recognizer.startListening(recognizerIntent); 
    }