Start Python unbuffered flushes print to stdout
This commit is contained in:
parent
0c2cdfdf59
commit
9094fe940c
2 changed files with 6 additions and 14 deletions
|
@ -9,4 +9,4 @@ COPY requirements.txt .
|
||||||
RUN pip3 install -r requirements.txt
|
RUN pip3 install -r requirements.txt
|
||||||
COPY detect.py .
|
COPY detect.py .
|
||||||
|
|
||||||
CMD [ "python3", "detect.py", "-c", "/config/config.yaml"]
|
CMD [ "python3", "-u", "detect.py", "-c", "/config/config.yaml"]
|
||||||
|
|
18
detect.py
18
detect.py
|
@ -63,8 +63,7 @@ def load_config(config_file):
|
||||||
config = {**default_config, **config_override}
|
config = {**default_config, **config_override}
|
||||||
if not config["udp_ports"]:
|
if not config["udp_ports"]:
|
||||||
print(
|
print(
|
||||||
"No UDP ports configured. Configure UDP ports to receive audio for wakeword detection.",
|
"No UDP ports configured. Configure UDP ports to receive audio for wakeword detection."
|
||||||
flush=True,
|
|
||||||
)
|
)
|
||||||
exit()
|
exit()
|
||||||
return config
|
return config
|
||||||
|
@ -84,9 +83,7 @@ class RhasspyUdpAudio(threading.Thread):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Thread to receive UDP audio and add to processing queue."""
|
"""Thread to receive UDP audio and add to processing queue."""
|
||||||
print(
|
print(f"Listening for {self.roomname} audio on UDP port {self.port}")
|
||||||
f"Listening for {self.roomname} audio on UDP port {self.port}", flush=True
|
|
||||||
)
|
|
||||||
while True:
|
while True:
|
||||||
data, addr = self.sock.recvfrom(RHASSPY_BYTES)
|
data, addr = self.sock.recvfrom(RHASSPY_BYTES)
|
||||||
audio = wave.open(io.BytesIO(data))
|
audio = wave.open(io.BytesIO(data))
|
||||||
|
@ -116,7 +113,7 @@ class Prediction(threading.Thread):
|
||||||
)
|
)
|
||||||
self.mqtt.connect(config["mqtt"]["broker"], config["mqtt"]["port"], 60)
|
self.mqtt.connect(config["mqtt"]["broker"], config["mqtt"]["port"], 60)
|
||||||
self.mqtt.loop_start()
|
self.mqtt.loop_start()
|
||||||
print("MQTT: Connected to broker", flush=True)
|
print("MQTT: Connected to broker")
|
||||||
|
|
||||||
self.oww = Model(
|
self.oww = Model(
|
||||||
# wakeword_model_names=["hey_mycroft", "dog"],
|
# wakeword_model_names=["hey_mycroft", "dog"],
|
||||||
|
@ -175,9 +172,7 @@ class Prediction(threading.Thread):
|
||||||
):
|
):
|
||||||
self.filters[wakeword]["active"] = False
|
self.filters[wakeword]["active"] = False
|
||||||
if moving_average > 0.1:
|
if moving_average > 0.1:
|
||||||
print(
|
print(f"{wakeword:<16} {activated!s:<8} {self.filters[wakeword]}")
|
||||||
f"{wakeword:<16} {activated!s:<8} {self.filters[wakeword]}", flush=True
|
|
||||||
)
|
|
||||||
return activated
|
return activated
|
||||||
|
|
||||||
def __publish(self, wakeword, roomname):
|
def __publish(self, wakeword, roomname):
|
||||||
|
@ -194,10 +189,7 @@ class Prediction(threading.Thread):
|
||||||
"customEntities": None,
|
"customEntities": None,
|
||||||
}
|
}
|
||||||
self.mqtt.publish(f"hermes/hotword/{wakeword}/detected", dumps(payload))
|
self.mqtt.publish(f"hermes/hotword/{wakeword}/detected", dumps(payload))
|
||||||
print(
|
print(f"MQTT: Published wakeword {wakeword}, siteId {roomname} to Rhasspy")
|
||||||
f"MQTT: Published wakeword {wakeword}, siteId {roomname} to Rhasspy",
|
|
||||||
flush=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue