Attach python listeners before await functions

This commit is contained in:
Apher 2026-07-17 03:38:07 +00:00
parent 6e8c689639
commit 882bc00916

View File

@ -147,11 +147,7 @@ async function processor(group, consumer, streamKey) {
}
async function main() {
await redis.connect();
await redis.ensureGroup("commands", "assistant");
await playAudio("Assistant, online.");
// Attach python listeners FIRST to avoid missing logs
py.stdout.on("data", (data) => {
handlePythonOutput(data.toString(), async (msg) => {
if (msg.event === "text" || msg.event === "final") {
@ -168,7 +164,18 @@ async function main() {
console.log("Python exited with code", code);
});
try {
await redis.connect();
await redis.ensureGroup("commands", "assistant");
await playAudio("Assistant, online.");
// Start the command processor
processor("assistant", `${config.DEVICE_ID}`, "commands").catch(console.error);
console.log("System fully initialized.");
} catch (err) {
console.error("Initialization failed:", err);
}
}
main().catch(console.error);