swift 语音识别器?.supportsOnDeviceRecognition始终返回false

mo49yndu  于 2023-01-01  发布在  Swift
关注(0)|答案(1)|浏览(255)

我刚刚更新到macOS 10.15.4,每次我检查设备上的语音识别是否可用时,我都返回false。

speechRecognizer?.supportsOnDeviceRecognition = true
print("supportsOnDeviceRecognition: \(String(describing: speechRecognizer?.supportsOnDeviceRecognition))")

有人看到了吗?有什么办法能让它重新工作吗?

ctehm74n

ctehm74n1#

请注意,supportsOnDeviceRecognition取决于区域设置。如果您使用目标区域设置初始化SFSpeechRecognizer,则它将开始返回true(假设设备上已下载了区域设置Siri词典):

var unLocalizedSpeechRecognizer = SFSpeechRecognizer.init()
// unLocalizedSpeechRecognizer.supportsOnDeviceRecognition is most likely `false`

// change en-US to whatever locale you are targeting
var localizedSpeechRecognizer = SFSpeechRecognizer.init(locale: Locale(identifier: "en-US"))
// localizedSpeechRecognizer.supportsOnDeviceRecognition is most likely `true`
// if that local has been downloaded

相关问题