fix(dictate): finish Muse on final transcript
This commit is contained in:
@@ -422,8 +422,11 @@ class QueuedCloudTurn:
|
||||
self._provider_event_bytes -= size
|
||||
raise ProviderError(self._provider_prefix + "_event_overflow", "provider event queue is full") from error
|
||||
except ProviderError as error:
|
||||
# Preserve a provider failure that races with successful
|
||||
# finalization. Cancellation does not consume this error, but it
|
||||
# avoids recursively closing a transport we are already closing.
|
||||
self._receiver_error = error
|
||||
if not self._cancel_event.is_set():
|
||||
self._receiver_error = error
|
||||
self._abort_transport()
|
||||
except Exception:
|
||||
if not self._cancel_event.is_set():
|
||||
|
||||
@@ -177,13 +177,10 @@ class MetaTurn(QueuedCloudTurn):
|
||||
|
||||
def _finish_provider(self) -> str:
|
||||
deadline = time.monotonic() + self._timeout
|
||||
transcript: str | None = None
|
||||
while time.monotonic() < deadline:
|
||||
event = self._next_provider_event(max(0.01, deadline - time.monotonic()))
|
||||
if event is None:
|
||||
if transcript is None:
|
||||
raise ProviderError("meta_premature_close", "Meta closed without a final transcript")
|
||||
return transcript
|
||||
raise ProviderError("meta_premature_close", "Meta closed without a final transcript")
|
||||
_validate_meta_event(event)
|
||||
event_type = event["type"]
|
||||
if event_type == "error":
|
||||
@@ -198,11 +195,9 @@ class MetaTurn(QueuedCloudTurn):
|
||||
if isinstance(value, Mapping):
|
||||
value = value.get("text")
|
||||
try:
|
||||
transcript = bounded_provider_text(value)
|
||||
return bounded_provider_text(value)
|
||||
except ProviderError as error:
|
||||
raise ProviderError("meta_malformed_event", "Meta sent an invalid transcript") from error
|
||||
# Keep reading until the provider's normal close. A subsequent
|
||||
# error or abnormal close therefore cannot be mistaken for success.
|
||||
raise ProviderError("meta_timeout", "timed out waiting for Meta final transcript")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user