diff --git a/examples/speech-to-text/dataflow.yml b/examples/speech-to-text/dataflow.yml index bad75e7e..1742bd9f 100644 --- a/examples/speech-to-text/dataflow.yml +++ b/examples/speech-to-text/dataflow.yml @@ -2,6 +2,8 @@ nodes: - id: dora-microphone build: pip install -e ../../node-hub/dora-microphone path: dora-microphone + inputs: + tick: dora/timer/millis/2000 outputs: - audio diff --git a/node-hub/dora-microphone/dora_microphone/main.py b/node-hub/dora-microphone/dora_microphone/main.py index cb65b6ac..d709dc7b 100644 --- a/node-hub/dora-microphone/dora_microphone/main.py +++ b/node-hub/dora-microphone/dora_microphone/main.py @@ -16,6 +16,8 @@ def main(): start_recording_time = tm.time() node = Node() + always_none = node.next(timeout=0.001) is None + # pylint: disable=unused-argument def callback(indata, frames, time, status): nonlocal buffer, node, start_recording_time @@ -32,5 +34,10 @@ def main(): with sd.InputStream( callback=callback, dtype=np.int16, channels=1, samplerate=SAMPLE_RATE ): - while True: - sd.sleep(int(100 * 1000)) + event_stream_is_none = False + while not event_stream_is_none: + if not always_none: + event = node.next() + event_stream_is_none = event is None + else: + sd.sleep(int(1000))