|
|
@@ -666,6 +666,13 @@ class Worker:
|
|
|
except Exception:
|
|
|
logger.exception("TTS failed")
|
|
|
|
|
|
+ async def _send(self, msg: dict):
|
|
|
+ try:
|
|
|
+ await self.room.local_participant.publish_data(
|
|
|
+ json.dumps(msg, ensure_ascii=False).encode(),
|
|
|
+ reliable=True, topic="transcription",
|
|
|
+ )
|
|
|
+ except Exception:
|
|
|
pass
|
|
|
|
|
|
|
|
|
@@ -678,9 +685,6 @@ async def main():
|
|
|
await Worker(a.room).run()
|
|
|
|
|
|
|
|
|
-if __name__ == "__main__":
|
|
|
- asyncio.run(main())
|
|
|
-
|
|
|
def _drain_queue(q: "asyncio.Queue") -> None:
|
|
|
"""Discard any queued-but-not-yet-played TTS audio."""
|
|
|
while not q.empty():
|
|
|
@@ -689,3 +693,7 @@ def _drain_queue(q: "asyncio.Queue") -> None:
|
|
|
except Exception:
|
|
|
break
|
|
|
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ asyncio.run(main())
|
|
|
+
|