【问题标题】:Android studio Speech to text offline mode not workingAndroid studio Speech to text 离线模式不起作用
【发布时间】:2020-02-12 18:05:09
【问题描述】:

我正在尝试在我正在 Android Studio 中开发的 Android 应用程序上使语音文本脱机工作。这是我用来设置语音识别器的代码。

    public void openSpeechMode(View view) {

        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());

        if(intent.resolveActivity(getPackageManager()) != null) {
            startActivityForResult(intent, 10);
        } else {
            Toast.makeText(context, "Your device does not support Speech Input.", Toast.LENGTH_LONG).show();
        }

    }

当我在线时这很好用,但当我离线时它不起作用。我读到我需要确保在我的 Android 设备上遵循以下这些步骤...以确保我的设备具有在离线模式下工作所需的库。

1)Go to Settings
2)Click on “Language and input”
3)Select Google voice typing
4)Select Offline speech recognition
5)Install desired language
6)Once the download was done, turn off the internet and test it !!

我按照这些步骤操作,并且在我的安卓设备上安装了英语(英国)和英语(美国)。但是当我离线时,语音到文本应用程序仍然无法正常工作。当我单击麦克风时,我收到“网络未连接”“重试”的消息。

我做错了吗?有人可以帮忙吗? 谢谢

【问题讨论】:

    标签: android android-studio speech-to-text offline-mode


    【解决方案1】:

    你可以试试这个来设置你的语言偏好。

    String languagePref = "en-US";//as you have downloaded US english model
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, languagePref);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, languagePref); 
    intent.putExtra(RecognizerIntent.EXTRA_ONLY_RETURN_LANGUAGE_PREFERENCE, languagePref);
    

    【讨论】:

    • 这对我没有帮助。我也有同样的问题。仍然找不到解决方案。
    猜你喜欢
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-26
    • 1970-01-01
    • 2019-10-20
    • 1970-01-01
    相关资源
    最近更新 更多