Android离线语音识别

时间:2019-01-22 07:35:06

标签: android speech-recognition

我需要使用本地语音识别来实现android应用。我正在使用android Speech Recognizer进行相同操作。但这在离线环境中不起作用。有想法吗?

请参见下面的代码段。

    SpeechRecognitionListener h = new SpeechRecognitionListener();
    mSpeechRecognizer.setRecognitionListener(h);
    mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PROMPT,
            "Speech recognition demo");
    mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
    if (mSpeechRecognizer.isRecognitionAvailable(this))
        mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
                this.getPackageName());
    mSpeechRecognizer.startListening(mSpeechRecognizerIntent);

0 个答案:

没有答案