Comments (24)
Hello Guyz
i found a Hack to do this
just simply set your phone volume to 0 before listening start.
https://www.npmjs.com/package/react-native-system-setting
check this out
from voice.
Down vote
I really don't want this option exist in any RN project. It's not intuitively way to interact with client.
from voice.
any update?
from voice.
Any update on this??
from voice.
Any update?
from voice.
+1
from voice.
any update
from voice.
@MacKentoch Did you solved your problem?
from voice.
@lfoliveir4 no but try @vaibhgupta09 hack.
This is by design in Android: recording audio triggers a BIP sound -system does it - (should be related to legal reasons I guess).
So hacking is the only way to bypass as far as I know
from voice.
I'm not sure it's good idea to avoid that sound. This makes user to know about listening and as far as this library can start listen without user action it's better to keep BIP sound turned on.
from voice.
Any news on that @MacKentoch ?
I would also like to remove that sound.
from voice.
This would be a nice option.
from voice.
@ghsdh3409 Ping. Time to sync with upstream?
from voice.
have u been able to do that?
from voice.
I (big) while ago, I made a plugin for Cordova, and came up with a dirty hack to turn the volume off while recognizing and turn it back on when done. It's not the best solution but it works fine for now. I don't know exactly how to implement it now because it's been ages since I work with android, but just for the heck of it, here's the code of that class: https://github.com/dalvallana/ContinuousSpeechRecognizer/blob/master/src/android/ContinuousSpeechRecognizer.java. Look for the mStreamVolume
variable.
from voice.
any update?
from voice.
I also need such a function
from voice.
any Updateee?
from voice.
But it would be good if I could change that sound. I've seen solution for Android API. Maybe I will try it later
from voice.
bump
from voice.
wait this option
from voice.
any update?
from voice.
Any updates?
from voice.
Navigate to this file in: node_modules/@react-native-voice/voice/android/src/main/java/com/wenkesj/voice/VoiceModule.java
And there you can use the AUDIO_SERVICE
to manipulate the sound on the mobile on android so when the microphone is on silent the phone and when is done to return to the volume levels that the user has.
here a sample that i have try and work.
The patch encompasses the implementation of an Android-based speech recognition feature in a React Native application. It allows the application to mute background sound or music while the Speech Recognizer is capturing user speech. This has been achieved by employing the AudioManager, a core Android service that handles audio management, including volume and mode.
At the start of the VoiceModule class, a private field for AudioManager and an integer field for StreamVolume is declared. The AudioManager is later used to manage audio properties when the microphone is active.
private AudioManager mAudioManager = null;
private int mStreamVolume = 0;
The application stores the current music stream volume in the mStreamVolume variable when the VoiceModule object is created. This original volume level is maintained for restoration once the speech recognition operation is completed.
AudioManager mAudioManager = (AudioManager) this.reactContext.getSystemService(Context.AUDIO_SERVICE);
mStreamVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
When speech recognition begins, the application mutes the music stream volume. This ensures that the recognition process is not affected by any background music that might be playing.
muteStreamVolume();
speech.startListening(intent);
After the startListening() function is called, the muteStreamVolume() function mutes the audio stream only if the original volume wasn't 0.
private void muteStreamVolume() {
if(mStreamVolume == 0) {
return;
}
AudioManager mAudioManager = (AudioManager) this.reactContext.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
}
As soon as the recognition process is completed, the audio stream volume is restored to its original value. This is done in the onResults() method which is called when speech recognition results are ready.
setStreamVolumeBack();
The setStreamVolumeBack() function restores the original audio stream volume when called.
private void setStreamVolumeBack() {
AudioManager mAudioManager = (AudioManager) this.reactContext.getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mStreamVolume, 0);
}
In conclusion, this patch significantly improves the user experience by ensuring that a user's voice command is not drowned out by background music during a voice-activated operation. This subtle yet essential modification enables users to interact more seamlessly with voice-activated applications and commands.
IMPORTANT After you edit the library you need to patch the use this tool:https://www.npmjs.com/package/patch-package
search on the net to find out how is this done.
from voice.
Related Issues (20)
- Document on-device file transcription api for iOS and note no corresponding android api
- React native issues warning about NativeEventEmitter HOT 5
- `react-native-voice` Compatibility Issue with Android 13 ColorOS ROM ("13/Didn't understand, please try again.") HOT 3
- patata
- Remove background noise HOT 1
- "Cannot make recognizer for sq-AL. Supported locale identifiers are..." HOT 3
- Error with Android 13 (Code 9, Code 12) HOT 6
- Your JavaScript code tried to access a native module that doesn't exist. HOT 1
- Word Period Issue
- Repeated kAFAssistantErrorDomain error 1107 HOT 2
- Any plan to support contextualStrings on iOS and Android?
- Expo Android: Could not find method compile() for arguments HOT 3
- React Native Screen Recorder and Voice Recogniser does not work together
- Is there any way to ignore speaker output? HOT 3
- Single letter or Alphabet only not recognize
- Bluetooth recognition crash
- Error in Android Build Process: Deprecated Configurations and Implicit Dependencies in @react-native-voice_voice Module HOT 4
- Cannot update listeners while Voice is recording.
- intergrate with WebRTC
- Facing build error after manually linking in android HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from voice.