Home » Java » Increase listening timeout in DialogFlow (api.ai) Android SDK

Increase listening timeout in DialogFlow (api.ai) Android SDK

Posted by: admin July 12, 2018 Leave a comment

Questions:

What I’ve done?

I have created a chatbot using the Android SDK of api.ai a.k.a DialogFlow. My chatbot takes input in the form of voice and then the response is converted back into speech from the text using google TTS.

I have created an always listening mode by looping the listener just like this:-

@Override
public void onListeningCanceled() {
   aiService.resume();
}

@Override
public void onListeningFinished() {
   aiService.resume();
}

@Override
public void onError(AIError error) {
   aiService.resume();
}

This is working perfectly fine as the listening automatically resumes after any of these methods are called.

Actual Problem

But the problem arises when the bot is speaking (i.e. converting the text response to speech) and the listener has already started to listen to some input from the user.

The listener waits for a response for around 5-6 seconds but at this time the bot is actually speaking and hence the listener is unable to listen properly.

What do I need?

I want a solution where the listener would wait till the bot has spoken the complete response and after that, the listener resumes listening again.

This would allow the bot to be more conversational and would eliminate the need for the user to press the record button every time.

Answers: