Make espeak options and startup behavior configurable.

FossilOrigin-Name: 153d02185cc6e0ea224ef04593383612ca2f4795e62fda3d73750c8046cf7dad
This commit is contained in:
Mahlon E. Smith 2023-05-12 17:36:55 +00:00
parent e96f8d2f12
commit 65ac4ce493
2 changed files with 12 additions and 2 deletions

View file

@ -16,6 +16,7 @@ theremin:
gain_echo: 24
distance_max: 2
cancel_after: 3
startup_message: Hello. I'm Maude the bod. Lets make beautiful music together.
# font: /usr/share/sounds/sf2/FluidR3_GM.sf2
# glide: 1
# slew: 5

View file

@ -123,6 +123,13 @@ class Theremin
# Only change the note if the range finder value moves +/- this much
# between samples. This helps hold pitch, and avoids "warbles".
setting :slew, default: 5
##
# Optional message to speak at startup.
setting :startup_message, default: nil
## ESpeak TTL options.
setting :espeak_flags, default: %w[ -k20 -v f5 -s 160 -a 150 ]
end
@ -177,7 +184,7 @@ class Theremin
@threads << self.note_thread
@threads << self.gain_thread
self.led( :green )
self.speak "Hi. I'm Maude."
self.speak( self.class.startup_message ) if self.class.startup_message
self.log.warn "Waiting for interaction, or ctrl-c to exit."
@threads.map( &:join )
end
@ -268,7 +275,9 @@ class Theremin
##
def setup_speech
self.log.info "Starting background espeak process."
cmd = %w[ espeak -k20 -v f5 -s 160 -a 150 ]
cmd = [ 'espeak' ]
cmd << self.class.espeak_flags
cmd.flatten!
@speech_io, stdout, stderr, wait_thr = Open3.popen3( *cmd )
end