如何为 SpeechRecognizer Google SpeechToText APi 设置土耳其语

How to set Turkish Language for SpeechRecognizer Google SpeechToText APi

在我的应用程序中,我正在尝试创建一个从文本到语音的语音识别器 google Api 土耳其语并将 EXTRA_LANGUAGE_PREFERENCE 作为 "tr_TR" 来识别和 return 结果是土耳其语,但它能识别英语而不是土耳其语。

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);

土耳其语的语言代码是 "tr"。下面是我的使用方法。

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "tr");
    intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);

我在我的代码中解决了这个问题:

        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);