charles
charles

Reputation: 1

How can I do addSpeech() in TTS of Android?

I write simple program for tts. I want to study tts function. My code is below.

    String wakeUpText = "Are you up yet?";
    String destFileName = "/mnt/sdcard/hello.wav";
    mTts.addSpeech(wakeUpText, destFileName);
    mTts.speak(wakeUpText, TextToSpeech.QUEUE_ADD, null);

you can see the code is very like http://developer.android.com/resources/articles/tts.html

My problem is that if the hello.wav is not exist, tts cannot speak.

error log is below

DEBUG/MediaPlayer(398): java.io.IOException: Prepare failed.: status=0x1

...

DEBUG/SntpClient(70): request time failed: java.net.SocketException: Address family not supported by protocol

How can I do?

Upvotes: 0

Views: 858

Answers (1)

user479211
user479211

Reputation: 1554

Use just it:

String wakeUpText = "Are you up yet?";
mTts.speak(wakeUpText, TextToSpeech.QUEUE_ADD, null);

Not use:

String destFileName = "/mnt/sdcard/hello.wav";
mTts.addSpeech(wakeUpText, destFileName);

You have error message DEBUG/MediaPlayer(398): java.io.IOException: Prepare failed.: status=0x1 becouse you don't have the file

Upvotes: 2

Related Questions