加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

如何在swift中添加/更改语音语音性别到iOS应用程序?我正在使用A

发布时间:2020-12-14 05:24:26 所属栏目:百科 来源:网络整理
导读:我使用AVSpeechSynthesizer amp;创建了一个具有语音功能的应用程序.在TableView中显示来自AVSpeechSynthesisVoice:speechVoices()函数的语言列表.用户可以从TableView中选择语音语言. 我想要实现的下一件事是添加语音性别,以便用户可以在Siri app中切换默认
我使用AVSpeechSynthesizer& amp;创建了一个具有语音功能的应用程序.在TableView中显示来自AVSpeechSynthesisVoice:speechVoices()函数的语言列表.用户可以从TableView中选择语音语言.

我想要实现的下一件事是添加语音性别,以便用户可以在Siri app中切换默认的男性或女性声音.我不想让它变得复杂,只是寻找默认的男性或女性声音.

从speechVoices()返回的声音具有特定于每个声音的默认男声或女声.

我能改变它吗?我在应用程序设置页面上放置了一个UIPickerView,用于选择男声和女声.

但是,我做了一些研究,但没有找到任何文件.似乎在最新的iOS版本之前没有这样的支持.

到目前为止,有没有人试图实现这样的功能?

//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;
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读