本文介绍了AVSpeechSynthesizer 文本转语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
带有 en-us 语音的 AVSpeechsynthesizer 是A"的发音,是Capital A"但只想要A"怎么办?
AVSpeechsynthesizer with the en-us voice is pronunciation for "A" is "Capital A" but Just want "A" How can do that?
推荐答案
这只会在字符串中有单个字符时发生,
This only happens when there is single character in the string,
您可以使用此解决方法来检查字符串的长度是否为 1,然后将其转换为小写字符串,
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];
这篇关于AVSpeechSynthesizer 文本转语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!