2014-07-14 3 views
0

잘 작동하는 RecognizerIntent를 사용합니다 (아래 함수 참조). 내가 원하는 것은 오프라인 모드에서 실행하는 것입니다. RecognizerIntent가 좋은 해결책이 아닌 경우 대안이 무엇입니까? 그것은 당신이 "비행기 모드"및 테스트에 언어 영어 우릴에게오프라인 모드의 RecognizerIntent

recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "en-US"); 

이제 넣어 전화를 정의 할 필요가 나는 언어를 설정하는 것이 좋습니다 다른 해결책 ... 감사

public void speak(View view) { 
     Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
     // Specify the calling package to identify your application 
     intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getClass() 
       .getPackage().getName()); 

     // Display an hint to the user about what he should say. 
     intent.putExtra(RecognizerIntent.EXTRA_PROMPT, metTextHint.getText() 
       .toString()); 

     // Given an hint to the recognizer about what the user is going to say 
     intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 
       RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); 

     // If number of Matches is not selected then return show toast message 
     if (msTextMatches.getSelectedItemPosition() == AdapterView.INVALID_POSITION) { 
      Toast.makeText(this, "Please select No. of Matches from spinner", 
        Toast.LENGTH_SHORT).show(); 
      return; 
     } 

     int noOfMatches = Integer.parseInt(msTextMatches.getSelectedItem() 
       .toString()); 
     // Specify how many results you want to receive. The results will be 
     // sorted where the first result is the one with higher confidence. 

     intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, noOfMatches); 

     startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE); 
    } 
+0

당신은 특히 오프라인 모드를 요청할 수 없습니다 오프라인으로 작동합니다. 이 답변보기 http://stackoverflow.com/a/17674655/1256219 – brandall

답변

1

은 또한 경우 .

참고 - 그것은 단지 API-16 +