问题
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