iOS 13的新功能,您应该可以这样说(import Speech
:
let req = SFSpeechAudioBufferRecognitionRequest()
let loc = Locale(identifier: "en-US")
guard let rec = SFSpeechRecognizer(locale:loc)
else {print("no recognizer"); return}
print("rec isAvailable says: \(rec.isAvailable)")
if rec.supportsOnDeviceRecognition {
print("on device recognition")
req.requiresOnDeviceRecognition = true
} else {
print("no on device recognition")
}
问题是我在所有设备上都收到"no on device recognition"
。我可以做语音识别。我只是无法在设备上进行语音识别。此功能是真实的,还是Apple的理想?
答案 0 :(得分:2)
您可能在13.1上遇到supportsOnDeviceRecognition
的已知问题。来自iOS/iPadOS 13.1 Release Notes:
supportsOnDeviceRecognition
属性在首次访问时始终返回false。几秒钟后,再次访问它会返回正确的值。 (47822242)