开发者

How could i make flite (TTS) pause before speaking?

开发者 https://www.devze.com 2023-02-08 06:42 出处:网络
So this is the code I have: fliteEngine = [[FliteTTS alloc] init]; [fliteEngine setVoice:@\"cmu_us_awb\"];

So this is the code I have:

fliteEngine = [[FliteTTS alloc] init];

    [fliteEngine setVoice:@"cmu_us_awb"];
    [fliteEngine setPitch:12开发者_JS百科0.0 variance:50.0 speed:1.2];
    [fliteEngine speakText:fullScript];

And fullScript is an NSString with what i want it to say.

But because it takes a while to load, up to 3 minutes on the iPod Touch 1st gen, i want to load in what it's going to say and then, on my command, say it.

Anybody know how to do this? Because that last line, [fliteEngine speakText:fullScript]; seems to be the one that takes all the processing time, and which reads it out.


I think you don't have to load the whole string at once. You can divide it into smaller parts that could be loaded fast, and then just load new chunks each time the old one has already been pronounced. I'm not familiar with FliteTTS, but probably it has some method to preprocess the data. If yes, you can also divide your text into smaller chunks and while the current one is being pronounced you preload the next one in the separate thread.


Solution found..

In the fliteTTS.m file, i uncommented [audioPlayer prepareToPlay];, then cut the following code into a new 'startTalking' bit.

-(void)startTalking {


    [audioPlayer play];
    // Remove file
    [[NSFileManager defaultManager] removeItemAtPath:tempFilePath error:nil];
    delete_wave(sound);
}

Then i call the speakText first, but then call [fliteEngine startTalking]; and it works that way.


The flite library can save to a waveform file in a background thread. Then just play the sound after the file is ready.

0

精彩评论

暂无评论...
验证码 换一张
取 消