Reputation: 844
I'm developing an Android app where I need to have voice recognition, play audio through the speaker, and continuously record audio from the microphone simultaneously. The components I’m using include:
I have implemented the code for this functionality. Still, I’m experiencing performance issues where the phone's audio and video playback become choppy and stick for a few seconds approximately every 5 seconds. This disruption occurs even when I try to manage audio focus.
Here are my specific questions:
Here’s a simplified version of what I’m trying to achieve:
The SpeechRecognizer listens for commands. Depending on the recognized commands, I play an audio response using MediaPlayer. AudioRecord runs continuously in the background to capture audio.
Any advice, insights, or code samples for effectively managing these audio components while ensuring smooth performance would be greatly appreciated!
Upvotes: 1
Views: 56
Reputation: 130
Unfortunately, the SpeechRecognizer class doesn't have a property to listen continuously. This is why, when you play a video, you may notice issues with the play/pause functionality. The SpeechRecognizer stops listening for commands because it triggers the onEndOfSpeech() event, causing it to stop listening, and the video continues to play. If you restart the SpeechRecognizer, the video will pause again, and the SpeechRecognizer will start listening for commands, but only for a few minutes before stopping again.
To answer your question: Yes, you can achieve continuous listening, but not with SpeechRecognizer. For this functionality, I recommend using a continuous listening library like the Vosk library.
If you need help with this, feel free to ask. I've used this library before and can guide you through it.
For Source : Click Here
Upvotes: 0