iOS文本语音转换:由什么决定[AVSpeechSynthesisVoice voiceWithLanguage]返回的默认语音? [英] iOS text to speech: What decides the default voice returned by [AVSpeechSynthesisVoice voiceWithLanguage]?

查看:570
本文介绍了iOS文本语音转换:由什么决定[AVSpeechSynthesisVoice voiceWithLanguage]返回的默认语音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AVSpeechSynthesisVoice.voiceWithLanguage已在iOS SDK 7.0中引入.那时,每种语言/地区只有一种声音.

AVSpeechSynthesisVoice.voiceWithLanguage has been introduced in iOS SDK 7.0. At that time, there is only one voice per language/locale.

自iOS SDK 9.0起,已为每种语言/地区添加了更多声音.因此,Apple引入了新的API voiceWithIdentifier,以便您可以获取所需的特定语音.

Since iOS SDK 9.0, more voices have been added for each language/locale. So Apple introduces an new API voiceWithIdentifier so you can get the specific voice you want.

我的问题是,如果我们仍在iOS 9或更高版本中使用voiceWithLanguage,该怎么办?该API究竟返回什么?而且更重要的是,返回的语音是否在iOS版本之间甚至在不同设备之间发生了变化?

My question here is, what if we still use voiceWithLanguage in iOS 9 or above. What does this API exactly returns? And more importantly, does the returned voice changed between iOS versions and even between different devices?

我注意到,voiceWithLanguage返回的内容有点依赖于iOS语音设置设置->常规->辅助功能->语音->语音->英语".但并不是完全匹配.就是说,例如英语US,如果您将语音设置为"Fred",voiceWithLanguage将返回"Fred",这很酷.但是,如果将语音设置为"Nicky",voiceWithLanguage会返回"Nicky"以外的其他内容.

I've noticed that, what voiceWithLanguage returns is kind of relying on the iOS speech settings "ettings -> General -> Accessibility -> Speech -> Voices -> English". But not really exact match. That is to say, for example English US, if you set voice "Fred" voiceWithLanguage will return "Fred", which is cool. But if you set voice to "Nicky", voiceWithLanguage returns something else other than "Nicky".

我问这是因为我的应用程序正在使用voiceWithLanguage.当用户将iOS升级到iOS 12时,他们报告说他们听到了不同的声音.我相信voiceWithLanguage在升级到iOS 12后会返回不同的声音.虽然我无法在相同类型的设备上重现它.

I'm asking this is because my application is using voiceWithLanguage. And while user upgraded iOS to iOS 12, they reported that they heard a difference voice. I believe voiceWithLanguage is returning a different voice after upgrading to iOS 12. While I can't reproduce it on the same type of devices.

当然,我可以开始改用voiceWithIdentifier.但是只是对这个voiceWithLanguage感到好奇.

And of course I can start to use voiceWithIdentifier instead. But just curious about this voiceWithLanguage.

推荐答案

[尚无解决方案]我也遇到了同样的问题.

[NO Solution yet] I met the same issue, too.

首先,通过设置不同的声音

First, set different voice via

Accessibility -> Speech -> Voices
or 
Accessibility -> VoiceOver -> Speech -> Voices

然后

AVSpeechSynthesisVoice(language: language)

它不会影响iOS 12.0.1中的 AVSpeechSynthesizer (它适用于iOS 11.x和iOS 12.0.0)

It won't affect AVSpeechSynthesizer in iOS 12.0.1 (it works on iOS 11.x & iOS 12.0.0)

我还在iOS 12.0.1上发现了另外两件事

I also found two other things on iOS 12.0.1

首先,使用

AVSpeechSynthesisVoice(identifier: "com.apple.ttsbundle.siri_male_ja-JP_compact")

第二,如果我未设置语音识别符,则该区域设置中的女Siri 会说出文字.它也不受语音设置的影响.顺便说一句,我仍然找不到使男Siri 说话的方法,但是...哈哈

Second, if I don't set voice identifier, Female Siri in that locale will speak the text. It also doesn't affect by the speech settings in preference. BTW, I still cannot find anyway to make Male Siri Speak anything, yet... haha

这篇关于iOS文本语音转换:由什么决定[AVSpeechSynthesisVoice voiceWithLanguage]返回的默认语音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆