Skip to content

Commit 99c6297

Browse files
add echo behavior
1 parent ed86158 commit 99c6297

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

charts/doggo/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ spec:
6060
{{ if .Values.doggo.outputDevice }}
6161
- "--output-device={{ .Values.doggo.outputDevice }}"
6262
{{ end }}
63+
{{ if .Values.doggo.echo }}
64+
- "--echo"
65+
{{ end }}
6366
{{- with .Values.resources }}
6467
resources:
6568
{{- toYaml . | nindent 12 }}

charts/doggo/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ doggo:
99
robotIp: "192.168.1.100"
1010
# Whether to configure the input device
1111
configureInput: false
12+
# whether to echo the audio input to the speaker (for debugging)
13+
echo: false
1214
# explicitly set the output sample rate for the speaker device
1315
outputSampleRate: ~
1416

doggo.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)