harry0703/MoneyPrinterTurbo · error · TimeoutError
edge_tts stream timed out after {timeout_seconds:g}s
Error message
edge_tts stream timed out after {timeout_seconds:g}s What it means
Raised by a watchdog loop around an edge-tts chunk stream. Chunks are produced on a daemon thread into a queue; the main thread polls the queue with short timeouts against a monotonic deadline. If the deadline expires before a 'done' or 'error' item arrives (i.e. no item of any kind is delivered in time), a TimeoutError is raised.
Source
Thrown at app/services/voice.py:703
stream_queue = queue.Queue()
done_marker = object()
def _produce_chunks():
try:
for chunk in communicate.stream_sync():
stream_queue.put(("chunk", chunk))
stream_queue.put(("done", done_marker))
except Exception as e:
stream_queue.put(("error", e))
thread = threading.Thread(target=_produce_chunks, daemon=True)
thread.start()
deadline = time.monotonic() + timeout_seconds
while True:
remaining_seconds = deadline - time.monotonic()
if remaining_seconds <= 0:
raise TimeoutError(
f"edge_tts stream timed out after {timeout_seconds:g}s"
)
try:
item_type, payload = stream_queue.get(
timeout=min(0.5, remaining_seconds)
)
except queue.Empty:
continue
if item_type == "chunk":
on_chunk(payload)
elif item_type == "error":
raise payload
elif item_type == "done":
return
View on GitHub (pinned to 1f9f19c202)
Solutions
- Retry the request — edge-tts stream stalls are frequently transient; the caller should implement retry with backoff.
- Increase timeout_seconds so slow first-chunk latency does not trip the deadline.
- Check network egress to speech.platform.bing.com (proxy, firewall, DNS) from the host.
- Upgrade the edge-tts package if Microsoft changed endpoints or auth tokens (a common breakage source).
Example fix
# before
submaker = edge_tts_stream(text, voice, voice_file, timeout_seconds=5)
# after: tolerate slow first chunk and retry transient stalls
for attempt in range(3):
try:
submaker = edge_tts_stream(text, voice, voice_file, timeout_seconds=30)
break
except TimeoutError:
if attempt == 2:
raise Defensive patterns
Strategy: retry
Try / catch
for attempt in range(3):
try:
return edge_tts_stream(text, voice_name, voice_file,
timeout_seconds=30)
except TimeoutError:
if attempt == 2:
raise
time.sleep(2 ** attempt) Prevention
- Set timeout_seconds generously relative to text length and first-chunk latency.
- Monitor edge-tts package updates — endpoint/auth changes frequently cause stream stalls.
- Ensure unobstructed egress to the Edge TTS WebSocket endpoint (proxy/DNS).
When it happens
Trigger: Calling the edge_tts streaming wrapper with a small timeout_seconds while the network to Microsoft's TTS endpoint is slow or stalled; edge-tts connection established but no audio chunks arrive (service throttling/queueing); producer thread blocked inside Communicate.stream() awaiting the first bytes.
Common situations: Edge TTS transient outages or regional throttling; proxies/firewalls that allow the WebSocket handshake but stall the stream; timeout_seconds configured too aggressively for long texts where the first chunk takes a while; edge-tts library version change altering stream behavior after token/endpoint updates.
Understand the failure class
- Timeouts: ETIMEDOUT, deadlines, and hung requests — what actually expires when a request times out.
Related errors
- Sonilo stream ended before completion
- failed to connect to ElevenLabs: {exc}
- failed to request ElevenLabs music: {exc}
- failed to connect to Sonilo: {exc}
- Sonilo returned malformed streaming data
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/10e05643aae2e48e.
Report an issue: GitHub.