TextToSpeech volume

248 views
Skip to first unread message

Michael Seymour

unread,
Dec 7, 2016, 11:49:57 AM12/7/16
to DroidScript
Can it be changed? I've not seen any settings or parameters for it. Took me by surprise when I lowered my phone media volume and started my app in the middle of the night only to have the TextToSpeech in the app yell at me!

Symbroson Development

unread,
Dec 7, 2016, 12:19:44 PM12/7/16
to DroidScript
Use app.SetVolume( 'system', value );
value is between 0 and 1

Michael Seymour

unread,
Dec 7, 2016, 12:35:18 PM12/7/16
to DroidScript
Ahhh yes coz it's app.TextToSpeech
Didn't think of that, cheers!

Michael Seymour

unread,
Dec 8, 2016, 2:45:45 AM12/8/16
to DroidScript
One more question please, how many "streams" are there in SetVolume? Could I set the app's TextToSpeech volume to match the phone's master "Media" volume that TextToSpeech would otherwise ignore? Cheers!

Symbroson Development

unread,
Dec 8, 2016, 4:01:57 AM12/8/16
to DroidScript
TextToSpeech uses the system volume. There are also other streams like "Media" or "Notification" - I dont know all ^^

Michael Seymour

unread,
Dec 8, 2016, 4:16:50 AM12/8/16
to DroidScript
That's great thankyou :-) I'll stick a speech volume slider in my app's settings and have it match the general "sounds" volume

Steve Garman

unread,
Dec 8, 2016, 4:17:37 AM12/8/16
to DroidScript

The available streams are
alarm, dtmf, music, notification, ring, system, voicecall

Not all of these will be separate streams on most devices.

I believe the default stream is "system" although it used to be "music".

If I recall correctly, this was changed to fix a problem with using headphones.

You might want to use the "music" stream instead.

app.TextToSpeech( "hello",1,1,null,"music" );

Michael Seymour

unread,
Dec 8, 2016, 5:14:52 AM12/8/16
to DroidScript
Thankyou both, exactly what I need!

I'm using TextToSpeech for Tutorial instructions and various character voices (changing pitch and speed), making the file size a lot smaller without having to use voice sound clips!

Dave Smart

unread,
Dec 8, 2016, 8:26:58 AM12/8/16
to androi...@googlegroups.com
Note: You can use completely separate voice engines (download them from Google Play) and regional accents if you need to. 

I've attached a sample of using different voice engines for different voices.

You can also set the 'locale' parameter to make different accents if they are downloaded and available (works with the google voices)
VoiceSwitch.js

Dave Smart

unread,
Dec 9, 2016, 9:52:26 AM12/9/16
to DroidScript
Use strings like this in the locale parameter to change accents:-  "en_GB", "en_IN"

The first time you swap to a new locale, it will be delayed by a few seconds.... you could try working around that by speaking an empty sentence perhaps 3 seconds before needing to speak.

Mighty Apps Studio

unread,
Aug 31, 2018, 10:43:01 AM8/31/18
to DroidScript
I created a voice recognition app but the media volume is locked, i tried app.SetVolume("music",3); but nothing worked

Isaac Franks

unread,
Aug 31, 2018, 2:22:53 PM8/31/18
to DroidScript
I believe that the two parameters in Set.Volume are for the left and right side volumes, set between a value of 0 and 1 so what you wrote would not have produced results.

Steve Garman

unread,
Sep 1, 2018, 6:14:46 AM9/1/18
to DroidScript
I'm afraid you are wrong Isaac.

Your advice is correct for the level, which is the second argument but the first argument is for a string containing the stream name

Dan Flemming

unread,
Sep 7, 2018, 7:34:48 AM9/7/18
to DroidScript
I was wondering about the volume level but never asked how it could be modified.
Thanks Steve, I'll use your suggestion
app.TextToSpeech( "hello",1,1,null,"music" );
in my app so users can control the volume.

Thanks!
Dan
Reply all
Reply to author
Forward
0 new messages