cordova-plugin-tts
cordova-plugin-tts copied to clipboard
Volume
Is there anyway to just the volume of just the text to speech so that it works independent of other sounds that are being play (such as during an MP3 playing)
Your issue is now over a year old, but I have the same problem. Looking at the source, the fix looks pretty easy, but I have never built a Cordova plugin - and no iOS nor any experience, not even to mention Windows Phone.
For Android in TTS.java (line 192 in current HEAD), this code:
HashMap<String, String> ttsParams = new HashMap<String, String>();
ttsParams.put(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID, callbackContext.getCallbackId());
Needed to be extended by copying the 'volume' parameter (KEY_PARAM_VOLUME). For iOS it should be around where 'rate' is set in CDVTTS.m line 55. The API has also a volume parameter, according to the docs.
I've forked the repo and applied my idea from above: see commit in my cordova-plugin-tts fork It works! For 50% loundness you need to set volumen to about 0.2 by my perception. No idea how that will be on iOS or WP, maybe a good solution needs to apply some shaping of the factor to make it behave as similar as possible in a Cordova app.
To apply it to your project, you can use:
cordova plugin add https://github.com/mhoennig/cordova-plugin-tts
Anybody out there who could do it for iOS and WP?