gotev / android-speech

Android speech recognition and text to speech made easy
http://gotev.github.io/android-speech/
Apache License 2.0
473 stars 156 forks source link

Canceling SpeechRecognition #65

Closed Hokyjack closed 3 months ago

Hokyjack commented 1 year ago

Hi, is there any way to cancel the SpeechRecognition after it starts recording, so I don't have to wait until it stops because of silence. I can see there is a method cancel() in BaseSpeechRecognitionEngine, but there is no interface to access it. Is there any workouround around it? Thanks!

rehmanjameel commented 1 year ago

Yes, you can do it by using stopListening() method.

linearLayout.setOnClickListener(view -> {
            Speech.getInstance().stopListening();
            button.setVisibility(View.VISIBLE);
            linearLayout.setVisibility(View.GONE);
        });

linearlayout is the layout of progress view by clicking on layout you can stopListening. I hope this will be help full for you.