【问题标题】:synthesizeToFile failed: not bound to TTS engine , when using TextToSpeech in androidsynthesizeToFile 失败:未绑定到 TTS 引擎,在 android 中使用 TextToSpeech 时
【发布时间】:2013-05-11 13:21:08
【问题描述】:

我正在使用Android TextToSpeech API,我想将转换后的 text2speech 作为文件保存在 SD 卡内存中,但出现错误:

 synthesizeToFile failed: not bound to TTS engine

我使用 TTS 的代码是:

public void onActivityResult(int requestCode, int resultCode, Intent intent) {


        if (requestCode == MY_DATA_CHECK_CODE) {
            if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
                tts = new TextToSpeech(this, this);

                if(getIntent() != null){
                    if(getIntent().getExtras()!=null){
                        String d = getIntent().getExtras().getString("data");

                        String data[] = d.split("-");
                        bookName = data[0];
                        loadPage(data[0], Integer.parseInt(data[1]));
                    }
                }
                Log.d("TTS","Data is loaded");

            }
            else {
                Intent installTTSIntent = new Intent();
                installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                startActivity(installTTSIntent);
            }
        }
    }

loadPage() 函数内部调用synthesizeToFile 函数如下:

String tempDestFile = appTmpPath.getAbsolutePath() +"/"+ fileName;
tts.synthesizeToFile(speakTextTxt, myHashRender, tempDestFile);

【问题讨论】:

    标签: android text-to-speech speechsynthesizer


    【解决方案1】:

    您必须等到onInit 被调用之后才能调用speak, synthesizeToFile 等...在检查成功后将loadPage 方法放入onInit

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-07-31
      • 2021-01-24
      • 2014-02-25
      • 2016-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-18
      相关资源
      最近更新 更多