MCPcopy Create free account
hub / github.com/Roy3838/Observer / receive_transcripts

Function receive_transcripts

api/transcriptions.py:120–142  ·  view source on GitHub ↗

Deepgram → Browser: relay transcript events.

()

Source from the content-addressed store, hash-verified

118 pass
119
120 async def receive_transcripts():
121 """Deepgram → Browser: relay transcript events."""
122 nonlocal dg_dropped
123 try:
124 async for raw in dg_ws:
125 msg = json.loads(raw)
126 if msg.get("type") != "Results":
127 continue
128 transcript = (
129 msg.get("channel", {})
130 .get("alternatives", [{}])[0]
131 .get("transcript", "")
132 )
133 if transcript:
134 is_final = msg.get("is_final", False)
135 await websocket.send_json({"text": transcript, "is_final": is_final})
136
137 except websockets.exceptions.ConnectionClosed as e:
138 logger.info(f"Deepgram connection closed: {e}")
139 dg_dropped = True
140 except Exception as e:
141 logger.error(f"Transcript receive error: {e}")
142 dg_dropped = True
143
144 fwd = asyncio.create_task(forward_audio())
145 rcv = asyncio.create_task(receive_transcripts())

Callers 1

stream_transcriptionFunction · 0.85

Calls 2

infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected