My project uses iOS 10 speech recognition. For continuous speech, I use SFSpeechAudioBufferRecognitionRequest
from Apple's speech library, and saving the result to a UITextView
.
When the user pauses for x number of seconds, I want to add a period to the transcription, but the new transcription always overwrites the period because iOS speech saves the entire transcripton in a single string and keep appending to the string, then relays the result to my app continously.
For example: if my transcription was hello it's a test
and my UI correctly adds a period. But then the user records some more (without pressing the microphone button again because it's continuous), then the period will be overwritten because the speech engine does not know about the period, so it will be hello it's a test talking again
shown on the screen and I lose my edits. What is the best way to prevent this from happening?
This answer from another post suggests using a Timer. Using a Timer correctly adds a period but it doesn't solve the issue of speech engine not knowing about the period already being on the UI.