Cur*_*Dev 8 text-to-speech speech-synthesis ios avspeechsynthesizer swift
我创建了一个具有语音语音功能的应用程序,使用AVSpeechSynthesizer和显示AVSpeechSynthesisVoice: speechVoices()TableView中函数的语言列表.用户可以从TableView中选择语音语言.
我想要实现的下一件事是添加语音性别,以便用户可以在Siri app中切换默认的男性或女性声音.我不想让它变得复杂,只是寻找默认的男性或女性声音.
返回的声音speechVoices()具有特定于每个声音的默认男声或女声.
我能改变它吗?我已经UIPickerView在应用设置页面上放置了男声和女声之间的选择.
但是,我做了一些研究,但没有找到任何文件.似乎在最新的iOS版本之前没有这样的支持.
到目前为止,有没有人试图实现这样的功能?
Tom*_* C. -1
//NSArray* voices = AVSpeechSynthesisVoice.speechVoices;
//voice identifier inspection reports
//com.apple.ttsbundle.Samantha-compact
//com.apple.speech.synthesis.voice
//AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:text];
//Replace hard-coded name with any available in the list pulled from the speechVoices array
NSUInteger idx = [AVSpeechSynthesisVoice.speechVoices indexOfObjectPassingTest:^BOOL(AVSpeechSynthesisVoice * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
return [obj.identifier containsString:@"Samantha"];
}];
if (idx > -1) {
AVSpeechSynthesisVoice* voice = AVSpeechSynthesisVoice.speechVoices[idx];
utterance.voice = voice;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1189 次 |
| 最近记录: |