gpt4 book ai didi

ios - 使用 google API 或 AVspeech 的文字转语音

转载 作者:行者123 更新时间:2023-11-29 03:16:39 27 4
gpt4 key购买 nike

我需要使用某种文本转语音工具来发音多种语言。我试过这段代码:

 AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
AVSpeechSynthesizer *syn = [[[AVSpeechSynthesizer alloc] init]autorelease];
[syn speakUtterance:utterance];

哪个工作正常,但由于我想使用多种语言,它似乎没有这个功能还是什么?如何选择语言?

如果上述不可能,我想使用 Google api

这个怎么玩

http://translate.google.com/translate_tts?tl=en&q=Hello

在我的 View Controller 中?

最佳答案

这真的很简单,而且肯定有这个功能,试试下面的方法:

utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-gb"];

如果您需要了解所有可用的语言,请将以下代码放在某处:

NSArray* voices = [AVSpeechSynthesisVoice speechVoices];
NSLog(@"Voices: (%d) %@", voices.count, voices);

如果您需要有关 AVSpeechSynthesisVoice 的更多文档,请查看以下链接:

https://developer.apple.com/library/ios/Documentation/AVFoundation/Reference/AVSpeechSynthesisVoice_Ref/Reference/Reference.html

关于ios - 使用 google API 或 AVspeech 的文字转语音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21611497/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com