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

我使用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;
    }

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...