I use the speech recognition and text-to-speech but I would like to mute the "beep" sound of the speech recognition and then unmute for hear the vocal synthesis.
I succeed to mute but when I want to set the volume at its maximum, it applies to the phone and not to my app.
How to manage this ?
Thanks
There is an answer you can refer to here regarding how to loop the recognition and silence the beep.
Whenever you call setStreamMute() it is for the entire device, not just your application.
The issue here is that the Google Search Application (4.1+) is controlling the beep and the audio, it is not part of the recognition API.
If you open Google Now whilst you have music playing and press the listen button, you'll note that the music stops until the recognition and voice interaction finishes, this is because the app is 'ducking' the audio.
There is nothing as developers we can do about this behaviour (other than use another Speech Recognition Provider) and it's frustrating, as voiced here.
Until we manage to persuade Google to allow us to pass parameters such as 'offline' and 'no audio prompt' in the Recognition Intent, there's nothing we can do but rant.....
Related
I am working on an android music player and I wanna have hand-free voice commands,i.e., don't need to press any button to start recording. the app should keep listening all the time. Is there a way ?
You could use the Houndify SDK for voice recognition. It can be triggered without a button press, and it has music domains for searching and controlling music playback.
http://www.soundhound.com/houndify
I have app which have running offline voice recognition service listening for one keyword.
If keyword is spoken is triggered google speech recognition service which displays image like this and return text of spoken sentence.
I would like to know two things:
How to make app processing Google speech to text if app is not in
foreground or screen is locked?
How to avoid "Speak Now" Dialog? (I would like to use some custom
UI component)
Thanks for any advice.
If you want to run speech recognition in the background I would strongly advice you to stay way from google speech. You can currently run speech recognition in the background but it will cause a speech activation sound to be triggered every 3-5 seconds. See the question below:
Android Speech Recognition as a service on Android 4.1 & 4.2
Currently this sound runs on the music channel for some reason and therefore if you try to mute it music will be muted as well.
If you want to implement this the "nice" way I would suggest you take a look at cmusphinx.
I basically have an audio application that will be playing some music. I want to be able to pause/stop/mute the music when there is an interrupt.
These interrupts include: GPS directions, Phone Call, GPS, etc. (if there are more audio interupts, please let me know)
I already implemented the phone call interrupt, stops the music when phone call received and plays after phone call ends.
How would I do the other interrupts?
EDIT:
I noticed that Android's Play Music application does this. But I am unable to find the source code of that, not sure if that would be helpful.
Make sure you correctly ask for and release Audio Focus as described here:
http://developer.android.com/training/managing-audio/audio-focus.html
With multiple apps potentially playing audio it's important to think about how they should interact. To avoid every music app playing at the same time, Android uses audio focus to moderate audio playback—only apps that hold the audio focus should play audio.
Basically this allows the framework to handle interrupts properly as you cannot specifically code for every situation.
I want to build an android application which will recognize my voice, convert it into text and will show what i just spoke in a toast. i am able to do this by using a button which will launch voice recognizer for me. But now i want to make it work on the bases of my voice only.
The application should trigger voice recognizer and start listening to me only when i start speaking and should stop listening when it senses silence. Just like the functioning of talking tom application. There it records the voice but i want to recognize it using voice recognizer. Some thing like this:
if(no silense)
Launch Recognizer
else if(silence)
Stop Recognizer
Show toast
The main problem is that how can i sense if user is speaking something or not before launching voice recognizer. Is there any way to sense noise intensity..??
Secondly, is there any way to launch voice recognizer in the background...??
Is it possible if I can detect audio signal (someone starts speaking) in a background service, which will then immediately launch the voice recognizer to recognize the speech.
Most speech recognizers already have an endpointer to detect the start-of-speech and end-of-speech. Endpointers usually try to read the ambient noise level to determine a baseline for silence and to adapt the signal-to-noise ratio. But, if the input noise level changes, it might trigger the start-of-speech of the endpointer. If listening all the time, with a sensitive microphone, the endpointer might also pickup someone speaking next to you, instead of you.
As such, using a speech button is a good practice to announce when you wish to talk. Trying to get the recognizer to listen all of the time is probably not what you want to do, or should be left up to researchers.
Ok I have figured it out. I have used mediaRecorder class for this. When the application launches i start recording the audio using mediaRecoder (or you can provide a button to start and stop the whole process). I check for the amplitude of the audio being recorded by the mediaRecorder. If the amplitude passes over a predefined threshold, I pause the recording and launch the Voice Recognition activity. In OnActivityResult I again resume the recorder.
if(mRecorder != null){
int i= mRecorder.getMaxAmplitude(); // Getting amplitude
Log.d("AMPL : ", String.valueOf(i));
if(i>20000){ // If amplitude is more than 20000
onRecord(false); //Stop recording before launching recognizer
Intent intent=new Intent(this,VoiceRecognizer.class); //Launch recognizer activity
startActivityForResult(intent, 12112);
}
Alternatively: You can also use RecognitionListener interface as referred in this SO post.
I have an Android application that begins recording from the microphone when the application starts. In my current version, the user must press a STOP button to stop recording.
How do I detect that the user has stopped talking and use that to trigger the recorder to stop?
Similar to what is implemented in the Speech Recognition functionality in Android. The user stops talking and then the speech is translated. I have seen other apps that do it, like Talking Tom type apps.
As a side note I would also love to show some type of visual indicating that the microphone is receiving sound. Something to show the sound level coming in.
Any help appreciated.
An approach is to use threads on recording and the speech power analyzing process on the recorded bytes,
there's a sample code for your reference: http://musicg.googlecode.com/files/musicg_android_demo.zip
What are you using to record audio? This may provide some clues:
android.media.MediaRecorder:
the constant MEDIA_RECORDER_INFO_MAX_DURATION_REACHED can be used with an onInfoListener.
android.speech.SpeechRecognizer:
attach a RecognitionListener and call onEndofSpeech().