Dear Developer Forum,
I am an amateur python programmer and would like to use python in conjunction with the iOS Speech framework to do speech recognition. However, I’m getting stuck trying to figure out how to convert the following swift code snippet example from Apple documentation to request authorization from my device to python due to the example’s use of a terminal closure. I’d appreciate assistance from anyone in how I’d convert the code to python:
“
// Make the authorization request
SFSpeechRecognizer.requestAuthorization { authStatus in
// The authorization status results in changes to the
// app’s interface, so process the results on the app’s
// main queue.
OperationQueue.main.addOperation {
switch authStatus {
case .authorized:
self.recordButton.isEnabled = true
case .restricted:
self.recordButton.isEnabled = false
self.recordButton.setTitle("Speech recognition
restricted on this device", for: .disabled)
”
Thank you.
Sincerely,
Mike
I am an amateur python programmer and would like to use python in conjunction with the iOS Speech framework to do speech recognition. However, I’m getting stuck trying to figure out how to convert the following swift code snippet example from Apple documentation to request authorization from my device to python due to the example’s use of a terminal closure. I’d appreciate assistance from anyone in how I’d convert the code to python:
“
// Make the authorization request
SFSpeechRecognizer.requestAuthorization { authStatus in
// The authorization status results in changes to the
// app’s interface, so process the results on the app’s
// main queue.
OperationQueue.main.addOperation {
switch authStatus {
case .authorized:
self.recordButton.isEnabled = true
Code Block case .denied: self.recordButton.isEnabled = false self.recordButton.setTitle("User denied access to speech recognition", for: .disabled)
case .restricted:
self.recordButton.isEnabled = false
self.recordButton.setTitle("Speech recognition
restricted on this device", for: .disabled)
Code Block case .notDetermined: self.recordButton.isEnabled = false self.recordButton.setTitle("Speech recognition not yet authorized", for: .disabled) } }
}”
Thank you.
Sincerely,
Mike