iOS TTS文字转语音
iOS自带的文字转语音是iOS7以后才有的,需要AVFoundation 库。
AVSpeechSynthesizer: 语音合成器, 可以假想成一个可以说话的人, 是最主要的接口
AVSpeechSynthesisVoice: 可以假想成人的声音
AVSpeechUtterance: 可以假想成要说的一段话
语言种类 : Language
ar-SA 沙特阿拉伯(阿拉伯文)
en-ZA, 南非(英文)
nl-BE, 比利时(荷兰文)
en-AU, 澳大利亚(英文)
th-TH, 泰国(泰文)
de-DE, 德国(德文)
en-US, 美国(英文)
pt-BR, 巴西(葡萄牙文)
pl-PL, 波兰(波兰文)
en-IE, 爱尔兰(英文)
el-GR, 希腊(希腊文)
id-ID, 印度尼西亚(印度尼西亚文)
sv-SE, 瑞典(瑞典文)
tr-TR, 土耳其(土耳其文)
pt-PT, 葡萄牙(葡萄牙文)
ja-JP, 日本(日文)
ko-KR, 南朝鲜(朝鲜文)
hu-HU, 匈牙利(匈牙利文)
cs-CZ, 捷克共和国(捷克文)
da-DK, 丹麦(丹麦文)
es-MX, 墨西哥(西班牙文)
fr-CA, 加拿大(法文)
nl-NL, 荷兰(荷兰文)
fi-FI, 芬兰(芬兰文)
es-ES, 西班牙(西班牙文)
it-IT, 意大利(意大利文)
he-IL, 以色列(希伯莱文,阿拉伯文)
no-NO, 挪威(挪威文)
ro-RO, 罗马尼亚(罗马尼亚文)
zh-HK, 香港(中文)
zh-TW, 台湾(中文)
sk-SK, 斯洛伐克(斯洛伐克文)
zh-CN, 中国(中文)
ru-RU, 俄罗斯(俄文)
en-GB, 英国(英文)
fr-FR, 法国(法文)
hi-IN 印度(印度文)
NSString *language = @"en-US"; AVSpeechSynthesizer *speechSynthesizer = [[AVSpeechSynthesizer alloc]init]; AVSpeechSynthesisVoice *voice = [AVSpeechSynthesisVoice voiceWithLanguage:language]; AVSpeechUtterance *utterance =[AVSpeechUtterance speechUtteranceWithString:text]; //要读的文字 utterance.voice = voice; utterance.rate = 0.5;//语速0~1 utterance.pitchMultiplier = 0.5;//声调0.5~2 utterance.volume =1.0; [speechSynthesizer speakUtterance:utterance];
还有代理提供的一些方法。
@protocol AVSpeechSynthesizerDelegate <NSObject> @optional - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didStartSpeechUtterance:(AVSpeechUtterance *)utterance; - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didFinishSpeechUtterance:(AVSpeechUtterance *)utterance; - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didPauseSpeechUtterance:(AVSpeechUtterance *)utterance; - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didContinueSpeechUtterance:(AVSpeechUtterance *)utterance; - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer didCancelSpeechUtterance:(AVSpeechUtterance *)utterance; - (void)speechSynthesizer:(AVSpeechSynthesizer *)synthesizer willSpeakRangeOfSpeechString:(NSRange)characterRange utterance:(AVSpeechUtterance *)utterance; @end
iOS 文本转语音比较简单,值得注意的一点是如果想要单独读一串英文字母比如dunnage,需要在每个字母之间加字符来分开,“_”会隔开字母而且不会读出来,“,”会有明显的停顿,但是在开头加字符会被读出来。一些字母可能会被识别成单词,比如qa,不会读q a ,这时只要转换成大写字母QA即可。
- iOS 文字转语音
- iOS 语音读文字so easy
- 安卓TTS文字转语音
- Android TTS 中文 文字转语音 使用TextToSpeech Svox
- Android TTS文字转语音开发
- iOS 10中如何搭建一个语音转文字框架
- VC用TTS实现文字语音朗读
- iOS 10中如何搭建一个语音转文字框架——swift
- iOS中 语音识别功能/语音转文字教程详解 韩俊强的博客
- 在BAE tomcat环境下实现讯飞TTS在线文字转语音
- 160617、使用espeak将文字转语音(TTS)
- iOS-文字转语音
- iOS中 语音识别功能/语音转文字教程详解 韩俊强的博客
- ios语音播报TTS
- IOS研究之IOS下TTS语音合成的几种方案
- iOS自带文本转语音技术(TTS)的实现即语音播报的实践
- TTS Service Extended (进程:com.google.tts)意外停止 恢复被阉割的TTS文字转语音功能
- TTS文字转语音工具汇总
- iOS开发TTS技术即文本转语音
- iOS项目开发—TTS技术的实现即语音播报(实现方法一)