@@ -51,10 +51,11 @@ class Doggo:
5151 awake = True
5252 alive = True
5353
54- def __init__ (self , voice = "burt" , alive = True , output_sample_rate = 48000 ):
54+ def __init__ (self , voice = "burt" , alive = True , output_sample_rate = 48000 , echo = False ):
5555 self .voice_id = VOICES [voice ]
5656 self .alive = alive
5757 self .robot = None
58+ self .echo = echo
5859 self .output_sample_rate = output_sample_rate
5960
6061 if self .alive :
@@ -224,6 +225,9 @@ def _listen_sync(self):
224225 audio = sd .rec (int (RECORDING_DURATION * sd .default .samplerate ), channels = 1 , samplerate = sd .default .samplerate )
225226 sd .wait ()
226227
228+ if self .echo :
229+ sd .play (audio , sd .default .samplerate )
230+ sd .wait ()
227231 # if sd.default.samplerate != 16000:
228232 # audio = librosa.resample(audio, orig_sr=sd.default.samplerate, target_sr=16000)
229233
@@ -294,7 +298,8 @@ async def loop(dog):
294298@click .option ("--output-sample-rate" , type = int , default = 0 )
295299@click .option ("--input-device" , type = str , default = "USB PnP" )
296300@click .option ("--output-device" , type = str , default = "UACDemo" )
297- def main (voice , alive , configure_input , sample_rate , output_sample_rate , input_device , output_device ):
301+ @click .option ("--echo/--no-echo" , is_flag = True , default = False )
302+ def main (voice , alive , configure_input , sample_rate , output_sample_rate , input_device , output_device , echo ):
298303 if configure_input :
299304 sd .default .device = (input_device , output_device )
300305 if sample_rate > 0 :
@@ -303,7 +308,7 @@ def main(voice, alive, configure_input, sample_rate, output_sample_rate, input_d
303308 print ("Number of devices: " , len (devices ))
304309 print ("Devices: " , json .dumps (devices , indent = 2 ))
305310
306- dog = Doggo (voice , alive , output_sample_rate )
311+ dog = Doggo (voice , alive , output_sample_rate , echo )
307312 asyncio .run (loop (dog ))
308313
309314
0 commit comments