-1
我正試圖讓語音在我的Mac上迅速處理文本。我發現了一些文章,但它們都是針對iOS的。我試圖遵循這一之一: http://www.appcoda.com/siri-speech-framework/語音到文本macOS swift playground
到目前爲止,這是我在遊樂場代碼:
//: Playground - noun: a place where people can play
import Cocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
import Speech
while true {
microphoneButton.isEnabled = false //2
speechRecognizer.delegate = self //3
SFSpeechRecognizer.requestAuthorization { (authStatus) in //4
var isButtonEnabled = false
switch authStatus { //5
case .authorized:
isButtonEnabled = true
case .denied:
isButtonEnabled = false
print("User denied access to speech recognition")
case .restricted:
isButtonEnabled = false
print("Speech recognition restricted on this device")
case .notDetermined:
isButtonEnabled = false
print("Speech recognition not yet authorized")
}
OperationQueue.main.addOperation() {
self.microphoneButton.isEnabled = isButtonEnabled
}
}
}
它與錯誤,「沒有這樣的模塊講話」
我的問題來了是,在macOS中可能嗎?在操場上可以嗎?
由於提前, Jersh
看起來像[語音庫](https://developer.apple.com/reference/speech)僅適用於iOS,因此您使用SFSpeechRecognizer時很不幸。 – TheAmateurProgrammer
這將作爲答案,謝謝! – Jersh