I'm developing an Android Voice Assistant (Using Dialogflow
), and I'm able to control when the user start the request.
@Override
public void onListeningStarted() {
ImageView fab_img = (ImageView)findViewById(R.id.fab_img);
fab_img.startAnimation(performAnimation);
}
And that start an animation for the mic icon. After that, when they finish the question or speech, I can use this to stop the animation.
@Override
public void onListeningFinished() {
ImageView fab_img = (ImageView)findViewById(R.id.fab_img);
fab_img.clearAnimation();
}
But if the user does not speak, and the mic just close after a period of time, I'm not able to detect that. I have tried with this:
@Override
public void onListeningCanceled() {
}
But it's not working, and with the result of the query, but no luck. Any ideas? Thanks.
EDIT------ The suggested solution of @sunil sunny looks fine
@Override
public void onAudioLevel(float level) {
}
Right now I'm working on the amount of time that the silence level needs to be produced.