Android STT-专有的机载识别器

时间:2019-07-23 11:25:29

标签: android speech-recognition google-speech-api android-speech-api

我有一篇关于Android Speech To Text的建设性文章

Android Speech to Text Api Google - notification

我了解到,当没有互联网连接时,Android使用其专有的板载识别器。

我的代码来自以下来源:https://jbinformatique.com/2018/02/16/android-speech-to-text-api-google-tutoriel/

private void startSpeechToText() {
        Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());
        intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
        intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
                "Speak something...");
        try {
            startActivityForResult(intent, 666);
        } catch (ActivityNotFoundException a) {
            Toast.makeText(getApplicationContext(),
                    "Sorry! Speech recognition is not supported in this device.",
                    Toast.LENGTH_SHORT).show();
        }
    }
    /**
     * Callback for speech recognition activity
     * */
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case 666: {
                if (resultCode == RESULT_OK && null != data) {
                    ArrayList<String> result = data
                            .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                    String text = result.get(0);
                    txtOutput.setText(text);
                }
                break;
            }
        }
    }

我的问题是数据可能很敏感,因此不应将其发送到外部服务器。

但是

  • 效果很好
  • 免费

那么-可以强制使用专有的车载识别器吗?

0 个答案:

没有答案