0

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.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
NodeMaster
  • 85
  • 1
  • 5
  • You can keep a "processed string" that contains the version you have displayed in your UITextView, and then diff the new string against it for updates. – CodeBender Jan 15 '19 at 23:08
  • @CodeBender true but that is going to be too expensive (processing & battery) for a lot of speech recognition no? – NodeMaster Jan 16 '19 at 00:07
  • @CodeBender also since the results are not final, the new transcription coming in could be different from the old one. So really can't just compare – NodeMaster Jan 16 '19 at 23:05

0 Answers0