AVSpeechSynthesizer Text-To-Speech

ε祈祈猫儿з 提交于 2020-01-06 03:59:05

问题


AVSpeechsynthesizer with the en-us voice is pronunciation for "A" is "Capital A" but Just want "A" How can do that?


回答1:


This only happens when there is single character in the string,

you can use this workaround of checking if lenght of string is 1 than convert it to lowercase string,

NSString *stringToUtter = @"A";
if (stringToUtter.length==1) {
    stringToUtter = [stringToUtter lowercaseString];
}
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:stringToUtter];
utterance.rate = AVSpeechUtteranceMinimumSpeechRate;
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-us"];
[self.synthesizer speakUtterance:utterance];



回答2:


The perfect pronunciation can be obtained thanks to the IPA notation (International Phonetic Alphabet), no need of workaround. :o)

Put an attributedString with its appropriate attribute as incoming parameter of the AVSpeechUtterance instance.

To get the phonemes, I suggest to use the iPhone feature located at Settings > General > Accessibility > Speech > Pronunciations (iOS 12) ⟹ see this WWDC 2018 video summary if you need further details.

Helpful information for the implementation can be found in this answer as well.



来源:https://stackoverflow.com/questions/38519154/avspeechsynthesizer-text-to-speech

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