How to transcribe audio into text in iOS10 using Speech.framework?
Asked
Active
Viewed 3,530 times
1 Answers
8
Its very simple, just few lines of code.
let recognizer = SFSpeechRecognizer()
let request = SFSpeechURLRecognitionRequest(url: audioFileURL)
recognizer?.recognitionTask(with: request, resultHandler: { (result, error) in
if let error = error {
print("There was an error: \(error)")
} else {
print (result?.bestTranscription.formattedString)
}
})
NOTE:
As with accessing other types of protected data, such as Calendar and Photos data, performing speech recognition requires the user’s permission (for more information about accessing protected data classes, see Security and Privacy Enhancements).
In the case of speech recognition, permission is required because data is transmitted and temporarily stored on Apple’s servers to increase the accuracy of speech recognition. To request the user’s permission, you must add the NSSpeechRecognitionUsageDescription key to your app’s Info.plist file.
Refer: http://saravnandm.blogspot.in/2016/06/ios10-speech-recognition-in-ios-10_23.html

SaRaVaNaN DM
- 4,390
- 4
- 22
- 30
-
Vow ! Is it really this much simple ? – Durai Amuthan.H Jun 22 '16 at 05:57
-
1yes apple made it very simple now. No need to use any third party frameworks. – SaRaVaNaN DM Jun 22 '16 at 05:59
-
Anything like text to speech available as part of apple's framework ? – Durai Amuthan.H Jun 22 '16 at 06:01
-
1Its available from ios 7 onwards. refer this http://stackoverflow.com/questions/22561926/ios-7-text-to-speech-api – SaRaVaNaN DM Jun 22 '16 at 06:02
-
No, you need an internet. As of now there is no offline support. – SaRaVaNaN DM Sep 02 '16 at 05:21
-
@SaRaVaNaNDM, No, it's not! That question is about TTS, not Speech to text. – Iulian Onofrei Oct 18 '16 at 09:56
-
I encountered the following error: `Error Domain=AVFoundationErrorDomain Code=-11838 "Cannot initialize an instance of AVAssetReader with an asset at non-local URL '/Users/.../CoreSimulator/Devices/3A...997/data/Containers/Data/Applicati ... ehEB.wav'`. Any idea? – Danny Wang Mar 05 '17 at 20:40