我在TTS代码中找不到错误

时间:2019-09-19 01:38:49

标签: java android cordova

我正在尝试使用cordova tts插件保存wav文件。由于我不懂Java语言,因此无法找出错误所在。您可以通过检查共享代码来告诉我哪里错了吗?

HashMap<String, String> ttsParams = new HashMap<String, String>();
        ttsParams.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackContext.getCallbackId());
        String exStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();
        File appTmpPath = new File(exStoragePath + "/sounds/");
        boolean isDirectoryCreated = appTmpPath.mkdirs();
        String tempFilename = "tmpaudio.wav";
        String tempDestFile = appTmpPath.getAbsolutePath() + File.separator + tempFilename;


        String[] localeArgs = locale.split("-");
        tts.setLanguage(new Locale(localeArgs[0], localeArgs[1]));

        if (Build.VERSION.SDK_INT >= 27) {
            tts.setSpeechRate((float) rate * 0.7f);
        } else {
            tts.setSpeechRate((float) rate);
        }
        tts.synthesizeToFile(text, ttsParams, tempDestFile);
        tts.speak(text, TextToSpeech.QUEUE_FLUSH, ttsParams);

Errod代码:

cannot find symbol
        String exStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath();

0 个答案:

没有答案