Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions aai_cli/tts/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import base64
import binascii
import collections
import contextlib
import json
from abc import abstractmethod
Expand Down Expand Up @@ -241,10 +242,10 @@ def _run_protocol(
as it arrives, so a caller can play it immediately; the full PCM is still
accumulated and returned."""
sample_rate = _begin_sample_rate(ws)
pending = list(texts)
pending = collections.deque(texts)
in_flight = 0
while pending and in_flight < _MAX_IN_FLIGHT:
_send_request(ws, pending.pop(0))
_send_request(ws, pending.popleft())
in_flight += 1

pcm = bytearray()
Expand All @@ -257,7 +258,7 @@ def _run_protocol(
# Exactly one per Flush, in order: every byte of that request is delivered.
in_flight -= 1
if pending:
_send_request(ws, pending.pop(0))
_send_request(ws, pending.popleft())
in_flight += 1
elif mtype == "Error":
raise APIError(f"TTS error {_error_frame_detail(msg)}")
Expand Down
Loading