Reputation: 87
I've been using PyObjC for recognizing text from audio file applying Speech framework. So I check documentation and create this small script, but he was returning an error. What's my error?
import Speech
def record():
recognize_request = Speech.SFSpeechRecognizer()
if not recognize_request.isAvailable():
raise NotImplementedError
nsurl = Speech.NSURL.fileURLWithPath_(u"/Users/aleksandr/PycharmProjects/flask/file.wav")
request = Speech.SFSpeechURLRecognitionRequest.alloc().initWithURL_(nsurl)
function = lambda func, err: func.bestTranscription.formattedString()
out = recognize_request.recognitionTaskWithRequest_resultHandler_(request, function)
return function(out, None)
print(record())
Error:
AttributeError: '_SFSpeechRecognitionBlockTask' object has no attribute 'bestTranscription'
I expect a a string with recognized text.
Upvotes: 0
Views: 8