2016-06-12 5 views
1

私のアプリケーションでは、トルコ語のテキスト音声認識google Apiを作成し、トルコ語で認識して結果を返すために "tr_TR"としてEXTRA_LANGUAGE_PREFERENCEを渡します英語はトルコ語ではない。SpeechRecognizer用のトルコ語を設定する方法Google SpeechToText APi

String lang_code="tr_TR";  
recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
      recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, 
        lang_code); 
      recognizerIntent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, lang_code); 
      recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, 
        this.getPackageName()); 
      recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 
        RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH); 
      recognizerIntent.putExtra(RecognizerInt 

ent.EXTRA_MAX_RESULTS, 3); 
+1

を?それはAndroid 2.3以降でサポートされている 'tr_TR'です。参照するには、この[post](http://stackoverflow.com/questions/7973023/what-is-the-list-of-supported-languages-locales-on-android)を参照してください。 –

+0

"tr-TR"を試しましたか? –

+0

OKですが、ロケールをどこでトルコ語に変更しますか? –

答えて

2

私は私のコードでその問題を修正:あなたはから `tur`を手に入れた

 language = "tr-TR"; 

     Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
     intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language); 
     intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 
     intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, language); 
     intent.putExtra(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES, language); 
     intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, language); 
     intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, language); 
     intent.putExtra(RecognizerIntent.EXTRA_RESULTS, language); 
     startActivityForResult(intent, REQUEST_CODE); 
0

トルコ語の言語コードは "tr"です。以下は私がそれを使った方法です。

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "tr"); 
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1); 
関連する問題