espeak-ruby
espeak-ruby copied to clipboard
espeak doesn't respect system's volume
Hi @dejan,
Thanks a bunch for working on this! \o/
However, I am using espeak-ruby like this:
speech = ESpeak::Speech.new("put on charging, your battery is at #{capacity}%.")
speech.speak
But even if the system's volume is low or on mute, ESpeak yells at full volume. :P
Is there a nice way to make sure it's in sync with the system volume? Let me know if it already exists and I haven't looked thoroughly. TIA!
Hey @utkarsh2102, so I think for this, it would be enough for the library to provide the amplitude option, mentioned in the command line options here, which you could then further use in your script.
@dejan it's just a matter of adding support for the -a option in the ESpeak::Speech module which I would be happy to do.
I hacked around a bit locally and the diff came out to look like the following:
diff --git a/lib/espeak/speech.rb b/lib/espeak/speech.rb
index f682905..c8e4ca5 100644
--- a/lib/espeak/speech.rb
+++ b/lib/espeak/speech.rb
@@ -12,6 +12,7 @@ module ESpeak
# :speed - speed in words per minute, 80 to 370
# :capital - increase emphasis of capitalized letters by raising pitch by this amount
# no range given in man but good range is 10-40 to start
+ # :amplitude - amplitude adjustment, 0 to 200
# :quiet - remove printing to stdout. Affects only lame (default false)
#
def initialize(text, options = {})
@@ -73,12 +74,13 @@ module ESpeak
pitch: 50,
speed: 170,
capital: 1,
+ amplitude: 100,
quiet: true }
end
def espeak_command(options, flags = '')
['espeak', @text.to_s, flags.to_s, "-v#{options[:voice]}", "-p#{options[:pitch]}", "-k#{options[:capital]}",
- "-s#{options[:speed]}"]
+ "-s#{options[:speed]}", "-a#{options[:amplitude]}"]
end
def std_lame_command(options)
PS: thanks to @rajudev for pointing the issue in @utkarsh2102's repository, which prompted me to contribute to this repository!
Hey @Animesh-Ghosh,
This is greatttt! Thank you! \o/
Hey @dejan, could you possibly take a look at this quick bug fix? This shall help us respect the system's volume whilst using the gem. TIA! :)
it's just a matter of adding support for the -a option in the ESpeak::Speech module which I would be happy to do.
@Animesh-Ghosh please create a PR and I'll merge
Yay, thank you! ❤️
@Animesh-Ghosh please create a PR and I'll merge
@dejan PR #22 created. Please check it out, thanks!
This is now available in just released v1.1.0. Thank you @utkarsh2102 and @Animesh-Ghosh.
Hi @dejan,
This is now available in just released v1.1.0.
Awesome, thank you very much! Can you please re-trigger the CI? It's weirdly failing on the last commit. :(
Hopefully just re-running the pipeline should suffice.