Swift NSSpeech合成器在macOS上获得Siri语音
有没有办法获取语音合成器的Siri语音Swift NSSpeech合成器在macOS上获得Siri语音,swift,macos,avfoundation,avspeechsynthesizer,nsspeechsynthesizer,Swift,Macos,Avfoundation,Avspeechsynthesizer,Nsspeechsynthesizer,有没有办法获取语音合成器的Siri语音NSSpeechSynthesizer.availableVoices()没有列出它们,但可能有未记录的技巧或其他什么 我也尝试过使用AVSpeech合成器,即使它很难在macOS 10.14+上使用,我也无法让它大声读出 我使用了一个游乐场来测试这一点,代码如下: Siri语音 我不知道有什么诀窍可以让Siri语音可用,我恐怕不可能通过公共API让它工作 NSSpeechSynthesizer和AVSpeechSynthesizer都使用speechs
NSSpeechSynthesizer.availableVoices()
没有列出它们,但可能有未记录的技巧或其他什么
我也尝试过使用
AVSpeech合成器
,即使它很难在macOS 10.14+上使用,我也无法让它大声读出
我使用了一个游乐场来测试这一点,代码如下:
Siri语音
我不知道有什么诀窍可以让Siri语音可用,我恐怕不可能通过公共API让它工作
和NSSpeechSynthesizer
都使用AVSpeechSynthesizer
(包含在speechsynthesizer.framework
中)ApplicationServices.framework
- 快速检查它,函数
检查包标识符(通过BuildDefaultVoiceList(bool)
将其与PermitAllVoices
,com.apple.VoiceOverUtility
)进行比较)com.apple.VoiceOverUtilityCacheBuilder
- 可能还有其他支票
/System/Library/Speech/voices
文件夹中。试图复制语音,更改Info.plist
值使其看起来像另一个语音,但仍然不可用/无法工作
你想走多远?你想禁用SIP,修改框架,预加载你的东西。。。值得吗
AVSpeechmacOS上的合成器
它是有效的,但它是有缺陷的,你必须时不时地终止服务
可用语音列表
AVSpeechSynthesisVoice.speechVoices().forEach{voice in
打印(“名称:\(voice.Name)语言:\(voice.Language)标识符:\(voice.Identifier)”)
}
通话
let outrance=avspeechoutrance(字符串:“Ahoj,jak se máš?”)
eartance.voice=AVSpeechSynthesisVoice(标识符:“com.apple.speech.synthesis.voice.zuzana.premium”)
let synthesizer=AVSpeechSynthesizer()
合成器。说话(说话)
他不说话吗?
当您调用speak(outreace)
时,将调用以下所有方法(委托)并按其应做的方式工作:
speechsynthesisd
进程,则会出现问题:
kill`pgrep speechsd`
然后再试一次,它为我解决了问题
附加语音安装
- 系统首选项-可访问性-语音
- 系统语音-单击并向下滚动,然后选择自定义
- 选择要安装的附加语音
AVSpeech访问它们合成器
API。不过,如果它指向与NSSpeechSynthesizer
相同的框架,我现在将坚持使用它。
import Cocoa
import AVFoundation
let string = "Hello, World!"
let utterance = AVSpeechUtterance(string: string)
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)