From 65ac4ce493d6f7be2381485abe9041b8ef4bebf9 Mon Sep 17 00:00:00 2001 From: mahlon Date: Fri, 12 May 2023 17:36:55 +0000 Subject: [PATCH] Make espeak options and startup behavior configurable. FossilOrigin-Name: 153d02185cc6e0ea224ef04593383612ca2f4795e62fda3d73750c8046cf7dad --- theremin/config.yml | 1 + theremin/lib/theremin.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/theremin/config.yml b/theremin/config.yml index 94ad2fd..e611490 100644 --- a/theremin/config.yml +++ b/theremin/config.yml @@ -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 diff --git a/theremin/lib/theremin.rb b/theremin/lib/theremin.rb index ac8d9b5..e0437d3 100755 --- a/theremin/lib/theremin.rb +++ b/theremin/lib/theremin.rb @@ -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