3

I use AVAudioEngine to record user talking, I want to achieve that when the user pauses or stops talking for over X seconds, will play back the sentence just recorded before.

But how can I detect this pause of talking during recording?? Haven't found useful API in AVAudioEngine, any idea to help me?

Abby Lin
  • 51
  • 4

1 Answers1

-1

You can set Timer inside

private let speechRecognizer = SFSpeechRecognizer(locale: Locale.init(identifier: "en-US"))!    speechRecognizer.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in         

}) block. At the time of calling speechRecognizer.recognitionTask set the start time and after each subsequent request inside timer check the difference between current time with the start time.If the difference is higher than X seconds, do whatever you want.

Sachin Kumaram
  • 900
  • 1
  • 10
  • 27