innFactory / react-native-dialogflow

A React-Native Bridge for the Google Dialogflow (API.AI) SDK
https://innfactory.de/softwareentwicklung/ui-ux/sprachsteuerung-mit-api-ai-in-einer-react-native-app/
MIT License
199 stars 63 forks source link

how can we avoid calling finishListening on iOS? #55

Closed sibelius closed 5 years ago

sibelius commented 5 years ago

it'd be cool to have the same behavior of Android?

can we implement this in a bridge?

any thoughts on this?

jgcmarins commented 5 years ago

facing same problem here

spoeck commented 5 years ago

I think it's an OS behavior. When you're using google assistant on android it automatically recognize if you're finished with speaking. If I remember correctly you have always hold a speech button if you're talking to Siri?!

sibelius commented 5 years ago

we should debounce on iOS I think

check this https://github.com/wenkesj/react-native-voice/issues/21

sibelius commented 5 years ago

gonna try to great a helper on react-native-voice soon to fix this

tks

Gi-lo commented 5 years ago

@sibelius I was facing this problem earlier in iOS as well. Sadly I currently have no time to create a PR, but I hope you can use the following code somehow.

mRecognitionTask = mSpeechRecognizer.recognitionTask(with: mSpeechRequest) { [unowned self] result, _ in

  // We got some results
  if let transcription = result?.bestTranscription {

    // Invalidate old timer if not nil
    self.mEndOfSpeechTimer?.invalidate()

    // Schedule new timer
     self.mEndOfSpeechTimer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false) { _ in
           self.stopRecognition()

           completion(transcription.formattedString)
    }
  }