How to covert text of 'words per minute' to speech rate using AVSpeechUtterance in iOS 7

妖精的绣舞 提交于 2019-12-25 03:06:56

问题


I want to convert "words per minute" to speech rate of AVSpeechUtterance.

How can I do this?

And can I get total time length of text using speech rate?

My code:

- (AVSpeechUtterance*)convertTextToSpeak:(NSString*)textToSpeak {
    AVSpeechUtterance *speechUtterance = [[AVSpeechUtterance alloc] initWithString:textToSpeak];
    speechUtterance.rate = 0.2; // default = 0.5 ; min = 0.0 ; max = 1.0
    speechUtterance.pitchMultiplier = 1.0; // default = 1.0 ; range of 0.5 - 2.0
    speechUtterance.voice = [self customiseVoice];
    return speechUtterance;
}

回答1:


As far as I know, neither is possible. The rate isn't equivalent to a particular number of words per minute, it depends on the actual text (how long the words are, how many pauses/punctuation...), the voice/language, etc. You can probably get an approximation by experimenting a bit though.

There's also no API to determine the length of an AVSpeechUtterance (except for measuring while it's spoken, but that's probably not what you want).



来源:https://stackoverflow.com/questions/25458127/how-to-covert-text-of-words-per-minute-to-speech-rate-using-avspeechutterance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!