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