gpt4 book ai didi

ios - 如何获取 iOS 7 AVSpeechUtterance 文本到语音的不同语言代码?

转载 作者:技术小花猫 更新时间:2023-10-29 10:57:23 26 4
gpt4 key购买 nike

我想使用 iOS 7 新的语音合成 API,我的应用程序本地化为法语和英语、德语、日语等。我想设置语言代码来阅读文本。如何获取语言代码?

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

最佳答案

您可以设置以下语言之一:

 for (AVSpeechSynthesisVoice *voice in [AVSpeechSynthesisVoice speechVoices]) {
NSLog(@" %@", voice.language);
}

或使用默认语言环境:

AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:@"Localized -text"];
utterance.rate = AVSpeechUtteranceMinimumSpeechRate; // Tell it to me slowly
[synthesizer speakUtterance:utterance];

更新

这是支持语言的列表:

Arabic (Saudi Arabia) - ar-SA
Chinese (China) - zh-CN
Chinese (Hong Kong SAR China) - zh-HK
Chinese (Taiwan) - zh-TW
Czech (Czech Republic) - cs-CZ
Danish (Denmark) - da-DK
Dutch (Belgium) - nl-BE
Dutch (Netherlands) - nl-NL
English (Australia) - en-AU
English (Ireland) - en-IE
English (South Africa) - en-ZA
English (United Kingdom) - en-GB
English (United States) - en-US
Finnish (Finland) - fi-FI
French (Canada) - fr-CA
French (France) - fr-FR
German (Germany) - de-DE
Greek (Greece) - el-GR
Hebrew (Israel) - he-IL
Hindi (India) - hi-IN
Hungarian (Hungary) - hu-HU
Indonesian (Indonesia) - id-ID
Italian (Italy) - it-IT
Japanese (Japan) - ja-JP
Korean (South Korea) - ko-KR
Norwegian (Norway) - no-NO
Polish (Poland) - pl-PL
Portuguese (Brazil) - pt-BR
Portuguese (Portugal) - pt-PT
Romanian (Romania) - ro-RO
Russian (Russia) - ru-RU
Slovak (Slovakia) - sk-SK
Spanish (Mexico) - es-MX
Spanish (Spain) - es-ES
Swedish (Sweden) - sv-SE
Thai (Thailand) - th-TH
Turkish (Turkey) - tr-TR

关于ios - 如何获取 iOS 7 AVSpeechUtterance 文本到语音的不同语言代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23827145/

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