I am conducting initial research on a new potential product. Part of this product requires Speech-To-Text on both iPhones and iPads to remain on until the user turns it off. Upon using it myself, I noticed that it either automatically shuts off after 30 or so seconds, regardless of whether or not the user has stopped speaking, OR it shuts off after there have been a certain amount of questionable words from the speaker. In any case, this product requires it to remain on all of the time until explicitly told to stop. Has anybody worked with this before? And yes, I have tried a good search, I couldn't seem to find anything of substance, and especially anything written in the right language. Thanks friends!
When you use Dictation on a device, you can dictate text of any length without a timeout. You can stop Dictation manually, or it stops automatically when you stop speaking for 30 seconds. Note: Dictation may not be available in all languages or in all countries or regions, and features may vary.
To enter text, tap the microphone button on your keyboard, then start speaking. As you speak, the text appears on the screen. To finish, stop speaking, then tap the keyboard button . If dictation isn't sure what word it heard, you'll see a blue line under the transcribed word so you can check it for accuracy.
import Speech
let recognizer = SFSpeechRecognizer()
let request = SFSpeechURLRecognitionRequest(url: audioFileURL)
#if targetEnvironment(simulator)
request.requiresOnDeviceRecognition = /* only appears to work on device; not simulator */ false
#else
request.requiresOnDeviceRecognition = /* only appears to work on device; not simulator */ true
#endif
recognizer?.recognitionTask(with: request, resultHandler: { (result, error) in
print (result?.bestTranscription.formattedString)
})
The above code snippet, when run on a physical device will continuously ("persistently") transcribe audio using Apple's Speech Framework.
The magic line here is request.requiresOnDeviceRecognition = ...
If request.requiresOnDeviceRecognition
is true and SFSpeechRecognizer#supportsOnDeviceRecognition
is true
, then the audio will continuously be transcribed until battery dies, user cancels transcription, or some other error/terminating condition occurs. This is at least true in my trials.
https://developer.apple.com/documentation/speech/recognizing_speech_in_live_audio
I found here a tutorial that show your speech. But see the notes:
Apple limits recognition per device. The limit is not known, but you can contact Apple for more information. Apple limits recognition per app.
If you routinely hit limits, make sure to contact Apple, they can probably resolve it.
Speech recognition uses a lot of power and data.
Speech recognition only lasts about a minute at a time.
EDIT
This answer was for iOS 10. I expect the release of iOS 12 at October 2018 but Apple still says:
Plan for a one-minute limit on audio duration. Speech recognition can place a relatively high burden on battery life and network usage. In iOS 10, utterance audio duration is limited to about one minute, which is similar to the limit for keyboard-related dictation.
See: https://developer.apple.com/documentation/speech
There are no API changes in the Speech
Framework for iOS 11 and 12. See all API changes and especially for iOS 12 in detail by Paul Hudson: iOS 12 APIs Diffs
So my answer should still be valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With