AVSpeechSynthesizer 文本转语音

编程入门 行业动态 更新时间:2024-10-15 02:32:51
本文介绍了AVSpeechSynthesizer 文本转语音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

带有 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 文本转语音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 19:31:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1398899.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:语音   文本   AVSpeechSynthesizer

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!