Skip to content

feat(stt): add native Gnani Prisma ASR extension - #2415

Open
ANAMASGARD wants to merge 8 commits into
TEN-framework:mainfrom
ANAMASGARD:feat/gnani-prisma-stt
Open

ANAMASGARD wants to merge 8 commits into
TEN-framework:mainfrom
ANAMASGARD:feat/gnani-prisma-stt

Conversation

@ANAMASGARD

@ANAMASGARD ANAMASGARD commented Nov 20, 2026 •

Copy link
Copy Markdown

Refs #2414

Changes

Add gnani_asr_python for live Prisma transcription and install it with the standard voice-assistant example. In local TMAN Designer, replace the existing stt node with Gnani and edit params.model to select prisma-v2.5 or prisma-v3.0. The default is v2.5 with en-IN. Both models accept a single locale, and v3.0 also supports indic-auto. Set GNANI_API_KEY in the agent environment.

The extension sends paced mono 16 kHz PCM, uses the provider's commit control when TEN requests finalization, and tracks outstanding utterances before acknowledging the request. It bounds its audio queue and reports transport failures. The provider has no transcript-drain acknowledgement. The adapter waits the full five seconds even when an earlier result has already arrived, reports outstanding speech at the deadline, and closes the turn’s connection to isolate late results. Segment offsets are estimates, and an interrupted connection can lose speech already transmitted.

Gnani in the local Designer picker

Local verification

Test branch head: 9da98c856. Used the TEN development container, TMAN 0.11.48, runtime 0.11.75, and ten_ai_base 0.7.65. The minimum base with connection-state reporting is 0.7.48. TMAN also refreshed existing lock entries to match the local extension manifests and resolved runtime packages.

  • The standalone suite passed 24/24 on ten_ai_base 0.7.48 and 24/24 on 0.7.65, including live overlapping turns. Lint scored 10/10. Live Guarder passed 13/13 each for v2.5, v3.0 fixed locale, and v3.0 auto detection (39 passed, 0 failed, 0 skipped). This includes one five-minute run per profile.
  • The continuous-input regression checks exact PCM on each socket, confirms that the second socket sends while the first remains open, and verifies ordered TEN transcripts and finalize IDs. The long-stream harness accepts the matching terminal acknowledgement when the last audio cycle has already delivered its final transcript.
  • Installed the voice-assistant example without a Gnani credential and verified the contents of the TMAN package.
  • Used Chrome to replace the existing STT node in a disposable graph and saved each model. Checked that the audio/result connections survived. Ran the saved node properties in the TEN extension tester with a fixture source and verified that two final transcripts reached the receiver for each model.
  • Built the voice-assistant Go worker, standalone API server and production playground. The server health endpoint and playground returned HTTP 200. Loaded the packaged extension into the compiled worker and transcribed two consecutive turns for each Designer-saved model.
  • Tested streaming, finalization IDs, terminal credential errors, connection transitions, and English/Hindi recognition. The provider rejected comma-separated locales on the tested deployment. Hindi recognition on synthetic audio varied, especially with v3.0 automatic detection.

Reproduce from ai_agents:

task lint-extension EXTENSION=gnani_asr_python
task test-extension EXTENSION=agents/ten_packages/extension/gnani_asr_python
for profile in prisma_v25 prisma_v30 prisma_v30_auto; do
  task asr-guarder-test EXTENSION=gnani_asr_python CONFIG_DIR=tests/configs/$profile -- -k "test_long_duration_stream or not test_long_duration_stream"
done

A new sending socket can overlap the retired turn's five-second drain. Up to two provider sessions can count against the credential's concurrent-session allowance. Each socket has independent segment tracking and timeline state; TEN receives results and finalize acknowledgements in turn order. Saturation or a prolonged outage can still exhaust the bounded audio queue.

Open review items on this commit concern bursts of sub-five-second turns under the two-session limit, retrying buffered tail audio, normal closure during handshake, and base-class finalize dispatch.

The live tests require a Gnani key. Set GNANI_DESIGNER_GRAPH to a saved graph to exercise its STT configuration. The cloud Store listing requires maintainer publication. The parent issue also tracks the separate Timbre TTS contribution.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@github-actions

Copy link
Copy Markdown

Findings

  1. [P1, merge blocker] Bound finalization even when queued audio cannot connect. In extension.py:285-294, the consumer waits for ready before removing an audio frame, so an asr_finalize behind that frame cannot reach the timeout in finalize(). For example, with auto_connect=false, audio followed by finalize and no trigger_connect leaves the request unanswered indefinitely. The ASR finalize contract MUST complete even while disconnected. Give queued finalize requests a bounded failure path while preserving the ordering of any audio that can still be sent, and test this through on_audio_frame/on_data, not only by calling finalize() directly.

  2. [P1, merge blocker] Do not use the settings acknowledgement as proof that all transcripts arrived. extension.py:209-210 and extension.py:391-398 complete as soon as settings_updated arrives and there are no already observed speech starts. The provider documents this event as confirmation of a settings update, not a transcript-drain acknowledgement, and the receiver explicitly accepts a transcript without a matching start. If the settings acknowledgement precedes that transcript, asr_finalize_end is emitted first; subsequent audio can update self.metadata before the old transcript arrives, attributing it to the next session. The fake socket always sends starts before the acknowledgement, so the existing test misses this ordering. Use a provider-guaranteed drain boundary, or a bounded and documented alternative that keeps the finalize context until the transcript is resolved; add a delayed/no-start transcript test.

  3. [P1, merge blocker] Acknowledge every finalize request, including reused IDs. extension.py:371-374 permanently suppresses every later request with the same (session_id, finalize_id). Two legitimate requests that reuse an ID therefore produce only one asr_finalize_end, contrary to the MUST requirement of exactly one response per request; the set also grows for the lifetime of a session. Track completion per queued request instead of retaining IDs forever, and test repeated IDs and consecutive silent requests.

  4. [P1, merge blocker] Report disconnection when the extension closes its own socket. extension.py:413-420 clears self.ws before cancelling the receiver, which makes the receiver's if self.ws is ws cleanup skip on_disconnected(). A finalize timeout and a session change both use this path, so observers can be left seeing connected while the transport is closed, including while a replacement is connecting. The connection-state MUST requires the disconnected transition on closure. Make one owner report the transition exactly once and test timeout, session replacement, and stop.

  5. [P1] Recover from transient outages beyond five attempts. extension.py:152-158 turns an ordinary temporary network/service outage into a permanent fatal latch after five retries, with no configurable limit or subsequent recovery. The ASR baseline SHOULD retry transient failures indefinitely with capped exponential backoff; a deviation needs a documented vendor limit, alternatives, and test evidence. Please implement the default policy or expose and document an intentional limit, and test recovery after more than five failed attempts.

  6. [P2, merge blocker] Classify normal closes and retain native vendor errors. extension.py:211-225 reports an error for a normal WebSocket close whenever any audio has been sent since the last finalize (dirty remains true even after an automatic transcript). A completed ConnectionClosedOK MUST NOT emit an ASR error. Separately, vendor error events discard the provider's message, and connection failures discard the HTTP status in vendor_info, substituting the constant prisma; this violates the MUST requirement to retain available native error details and prevents callers diagnosing the failure. Distinguish normal and abnormal closure by exception type and pass sanitized vendor details into vendor_info; cover both with tests.

  7. [P2, merge blocker] Follow the required base audio and configuration contracts. on_audio_frame never calls the base implementation, despite the lifecycle MUST requiring it to pass frames through the base serialized consumer. The replacement consumer must reimplement framework behavior and its drift is already visible in the disconnected-finalize case above. In addition, PrismaConfig is a dataclass rather than the mandated Pydantic model, and initialization never logs the redacted effective configuration with config:. Please use the required base path and configuration model/logging, or document a framework contract change and migration as required by the review baseline.

ASR checklist

  • Lifecycle: fail — base audio callback is bypassed.
  • Connection state: fail — explicit socket teardown omits the disconnected transition.
  • Buffering: fail — queued audio can indefinitely block a finalize request.
  • Finalize: fail — missing per-request acknowledgement for reused IDs and premature completion on settings acknowledgement.
  • Reconnect: fail — transient outages become permanently fatal after five attempts; the required deviation rationale and evidence are absent.
  • Result shape: pass for the fields constructed in the reviewed path; cross-session attribution remains affected by finding 2.
  • Metrics: fail for required standalone coverage of connect delay, TTFW/TTLW and session metadata; runtime values were not independently verified.
  • Tests: fail — add the failure and race cases above, plus the baseline's standalone status/redaction, fatal/no-retry, and metric coverage. The PR reports local runs, but no independent live-provider run was performed in this review.

@github-actions

Copy link
Copy Markdown

Findings

  1. [P1] Merge blocker: do not acknowledge a commit using a settings response — extension.py:384-400. settings_updated acknowledges a configuration update, not completion of transcription. If that response arrives before the speech_start/processing for the committed audio, both start collections are empty and finalize emits asr_finalize_end immediately; a transcript can then arrive after the caller has advanced to the next turn or session. The provider documents processing as the signal that transcription has begun, but this code ignores it. Track the actual outstanding segments and use a documented drain/completion condition (with the existing bounded fallback); add a test where the settings response precedes speech and transcript events.

  2. [P1] Merge blocker: retain each finalize request through disconnection — extension.py:287-296. A finalize queued behind an audio frame cannot reach its timeout path while the socket is unavailable: the consumer waits at the frame until ready or a fatal error. For example, with auto_connect=false, if audio and finalize arrive before trigger_connect, neither a retry nor a fatal error is scheduled and the caller waits indefinitely. Ensure the pending finalize has its own deadline even when earlier audio is buffered, preserving the ordering/drop policy, and test a disconnected queue with an audio frame followed by finalize.

  3. [P1] Merge blocker: make connection replacement and shutdown atomic — extension.py:102-108. A connection attempt only checks stopped before awaiting connect() and the handshake; stop_connection() cannot close this local socket and on_stop() does not cancel or await the in-flight attempt. If stop or a session replacement runs while the handshake is pending, it can subsequently install self.ws, create a receiver, and emit connected after shutdown or after a newer session starts. Guard connection attempts with a generation/swap lock, invalidate them on stop or replacement, and close any stale socket before publishing it. Add delayed-handshake stop and replacement tests. The direct _ensure_connection() in send_audio also violates the ASR MUST that recovery not run synchronously from the send path.

  4. [P1] Merge blocker: distinguish normal closure and report explicit disconnects — extension.py:217-228. A normal WebSocket iteration ends without an exception, but if any audio has been sent dirty remains true until finalize, so a normal close emits an ASR error even when there is no unfinished speech. Conversely, stop_connection() clears self.ws before cancelling the receiver, causing its identity guard to skip on_disconnected() entirely on a session replacement or finalize timeout. Classify normal and abnormal closes separately, report the actual transition when explicitly closing, and test both paths. Normal ConnectionClosedOK must not produce an ASR error under the merge baseline.

  5. [P2] Do not permanently disable recognition after a short transient outage — extension.py:152-158. Five failed retries set the fatal latch permanently, so a temporary outage leaves the session unable to recover even when the service comes back. The ASR baseline expects unlimited non-fatal retries with capped backoff by default; an optional retry ceiling must be explicit and configurable. Continue retrying until stop/fatal, or expose the limit and document the vendor limitation, alternatives, and test evidence for this SHOULD deviation. Cover a recovery after more than five transient failures.

  6. [P2] Merge blocker: satisfy configuration and lifecycle requirements — config.py:4-5, extension.py:79-95, extension.py:236-252. The new extension uses a dataclass rather than the required Pydantic config, never emits the required redacted config: log, and overrides on_audio_frame without calling the base method. These are explicit ASR MUST requirements; migrate the config/logging and integrate the bounded FIFO with the base lifecycle contract, with regression tests for invalid config and audio handling. No framework contract change or migration is documented in the PR.

ASR design review

  • Lifecycle: fail — base audio callback is bypassed and pending connection attempts can outlive stop.
  • Connection state: fail — normal and explicit closes are not reported correctly.
  • Buffering: fail — a disconnected frame can indefinitely delay a queued finalize when no connection attempt is scheduled.
  • Finalize: fail — a settings acknowledgement is used as a transcript completion fence.
  • Reconnect: fail — recovery occurs inside send_audio, replacement is not atomic, and the fixed retry ceiling lacks the required SHOULD-deviation rationale.
  • Result shape: pass for the fields constructed in the extension; ordering across finalize needs the fix above.
  • Metrics: unverified — the PR describes live verification, but the standalone tests do not cover metrics and the reported test head predates the current head.
  • Tests: fail — add the failure/race coverage above and the baseline's standalone connection/redaction, vendor error, metrics, dump, and timeline coverage; provide current-head guarder results. The existing fake always sends speech starts before the settings acknowledgement, so it cannot expose the finalize ordering bug.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@github-actions

Copy link
Copy Markdown
  1. [P1] Preserve pending transcript work across finalize (merge blocker). In extension.py:457-474, turn_results includes transcripts received before the commit. If an earlier utterance has already produced a result and the final utterance's processing/speech_start is delayed by more than 500 ms, the loop closes the socket before that utterance's transcript can arrive. Even with no earlier result, the deadline closes a still-live socket without an error when the provider has not sent a start event. This silently loses speech while acknowledging finalize. The ASR baseline requires a bounded completion path and recommends delivering final results first; this timing-based SHOULD deviation needs evidence for the chosen bounds and alternatives. Track work associated with the committed audio using a provider-supported boundary if available, and report an unresolved drain instead of silently treating it as success. Add a test with a pre-commit transcript and a later commit transcript arriving after the quiet interval.

  2. [P1] Reset outstanding processing when a connection is replaced (merge blocker). extension.py:151-158 clears the old socket's start and completion sets but leaves processing intact. If a socket drops after a processing event and before its transcript, the replacement inherits a positive counter; each new processing/transcript pair leaves that old count positive, so every later finalize waits five seconds, reports an interruption, and closes the replacement socket. Retire all old-generation pending work on disconnect/replacement and test a drop between processing and transcript, followed by a successful new turn. The ASR connection-replacement and same-session recovery requirements are MUSTs.

  3. [P2] Close the connection-state transition after invalid config (merge blocker). extension.py:115-117 returns immediately for the fatal configuration latch, but the base class wraps start_connection() and emits connecting before entering this method. With the default auto_connect, a missing/invalid key therefore leaves observers in connecting forever after the fatal error, despite there being no transport or retry. Complete the state transition to disconnected on this path, and cover invalid config through the actual start lifecycle. Closing every failed connection attempt is an ASR MUST.

  4. [P2] Include the required ASR vendor metadata in results (merge blocker). The ASRResult construction supplies no metadata; the base class only copies the input metadata and does not add asr_info. Normal input containing just session_id consequently produces results without the required metadata.asr_info.vendor. Populate asr_info with the vendor while preserving input metadata and test the emitted JSON shape. The result-shape requirement is an ASR MUST.

  5. [P2] Retire the finalize timing context when no final result arrives. extension.py:482-488 acknowledges silent, disconnected, and timed-out requests without clearing the base class's last_finalize_time. The base sets that timestamp for every request and consumes it only when a final result is sent, so the next unrelated utterance emits TTLW measured from the previous finalize. Clear the timing state when the handshake finishes without a result, and test a silent or failed finalize followed by a successful turn.

ASR checklist

  • Lifecycle: pass for the reviewed init/stop calls; current-head live lifecycle verification remains needed.
  • Connection state: fail — fatal configuration leaves the state connecting (finding 3).
  • Buffering: pass for the reviewed bounded FIFO and disconnected-finalize deadline.
  • Finalize: fail — the drain can silently discard a late transcript (finding 1).
  • Reconnect: fail — pending processing survives socket replacement (finding 2).
  • Result shape: fail — required vendor metadata is absent (finding 4).
  • Metrics: fail — a completed finalize can contaminate the next turn's TTLW (finding 5).
  • Tests: fail — add the cases above and required standalone status/redaction, metrics, dump, and timeline coverage. The PR's reported live/guarder verification identifies an older head; please provide results for the current head. This review did not run PR-head code or live-provider tests.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@github-actions

Copy link
Copy Markdown
  1. [P1] Preserve all committed segments until the drain boundary — extension.py:465-471. A single post-commit transcript followed by 500 ms without an already-observed speech_start or processing causes the socket to close. If a second committed segment's events arrive later, its transcript is silently lost even though asr_finalize_end is sent. Similarly, the five-second branch logs and treats the drain as successful when no start was observed, even if a delayed transcript is still pending. The provider limitation and fallback are documented, but the ASR baseline's final-result-before-finalize SHOULD deviation also needs evidence for these bounds and alternatives. Please use a provider-supported completion boundary if one exists, or report an unresolved drain and substantiate the chosen fallback; test two post-commit segments with the second delayed beyond the quiet interval, and a transcript delayed beyond the deadline.

  2. [P2, merge blocker] Do not report a completed normal close as an ASR error — extension.py:401-407. If a normal code-1000/1001 close races an audio send, ws.send() can raise ConnectionClosedOK. This is caught as WebSocketException, re-raised, and the consumer reports Prisma audio delivery interrupted; the finalize send has the same issue. The ASR baseline MUST NOT emit an ASR error for ConnectionClosedOK. Classify by exception type in all send/finalize paths, retain the disconnect and recovery behavior, and add a test that races a normal close with a send.

  3. [P2] Start finalize latency timing when the request arrives — extension.py:328-332. The base receives asr_finalize only when the serialized consumer reaches it, after any queued, paced audio has been sent. Its last_finalize_time therefore starts at dequeue rather than request arrival, so TTLW omits the potentially seconds-long queue delay experienced by the caller. Carry the request timestamp with each queued finalize and use it for the corresponding metric; test a finalize queued behind paced audio and verify TTLW includes that wait.

ASR checklist

  • Lifecycle: pass for the reviewed base calls and shutdown paths.
  • Connection state: fail — a normal close racing a send is reported as an error (finding 2).
  • Buffering: pass for the reviewed bounded queue and disconnected finalize fallback.
  • Finalize: fail — delayed committed segments can be lost (finding 1).
  • Reconnect: pass for the reviewed capped backoff and stop cancellation paths.
  • Result shape: pass for the reviewed constructed fields and live-test assertions.
  • Metrics: fail — TTLW omits queued audio delay (finding 3).
  • Tests: fail — add the scenarios above and the baseline's standalone connection/redaction, metrics, dump, and timeline coverage. The PR says current-head guarder results are still being collected. This review did not execute PR-head code or live-provider tests.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@github-actions

Copy link
Copy Markdown
  1. [P1, merge blocker] Keep accepting the next turn while the previous turn drains. extension.py:458-461 holds the only audio consumer for five seconds on every nonempty finalize, while the entire queue is capped at five seconds of PCM and the replacement connection adds at least another 250 ms before consumption resumes. With continuous real-time input, the queue necessarily overflows and on_audio_frame drops its oldest frames; if the user begins the next utterance during that interval, its beginning can be lost. The sender then runs at approximately real time, so it cannot quickly eliminate the accumulated delay. The standard voice-assistant graph forwards continuous RTC audio to STT. Decouple the old socket's drain from sending the next turn, or otherwise provide enough bounded capacity and a catch-up strategy without discarding the new turn. Add a test that continues streaming through finalize and reconnection, checks the exact audio sent, and exercises consecutive turns. The ASR buffering requirement requires an acceptable overflow policy that preserves session boundaries.

  2. [P2, merge blocker] Handle a normal close during the pacing delay. extension.py:394-397 snapshots the socket and sleeps before checking its identity. If the receiver processes a normal code-1000/1001 close during that sleep, it clears self.ws, so this check raises OSError; the consumer then emits Prisma audio delivery interrupted even though the close was normal. Catching ConnectionClosedOK at the consumer does not cover this race. Preserve the close classification when the socket disappears, and test a normal close during the pacing sleep. The ASR baseline MUST NOT emit an error for a completed normal WebSocket close.

  3. [P2, merge blocker] Validate the handshake JSON before accessing its fields. extension.py:145-149 assumes any valid JSON is an object. If the server or an intermediary returns null, a string, or an array, .get() raises AttributeError, which is outside the exception handler. The local socket is left open, the base state remains connecting, and no retry is scheduled. Validate the response type and route malformed handshakes through the existing cleanup and error path; cover this with a fake socket. The baseline requires failed handshakes to close the connection state.

  4. [P2] Substantiate and report an unconfirmed finalize drain. extension.py:477-481 only logs when the five-second window expires with no observed start/processing event, then closes the socket and acknowledges finalize. A transcript whose first event arrives after the deadline is therefore lost without a caller-visible indication. The PR documents the lack of a provider acknowledgement, but the baseline's final-result-before-finalize SHOULD requires evidence for the chosen bound and alternatives. Please report an unresolved drain through the error channel and provide evidence for the timeout and alternatives, including a test with the first transcript delayed beyond the deadline.

ASR checklist

  • Lifecycle: pass for the reviewed base lifecycle calls and stop cancellation.
  • Connection state: fail — malformed handshake and normal-close race (findings 2–3).
  • Buffering: fail — continuous input overflows during finalize and reconnect (finding 1).
  • Finalize: fail — an unconfirmed drain can discard a late result without notifying the caller (finding 4).
  • Reconnect: pass for the reviewed retry policy and stale-connection guards; interaction with continuous input fails as above.
  • Result shape: pass for the reviewed emitted fields and live-test assertions.
  • Metrics: pass for the reviewed finalize arrival timestamp handling; standalone metric coverage remains incomplete.
  • Tests: fail — add the scenarios above and the baseline's standalone connection/redaction, metrics, dump, and timeline coverage. The PR reports the standard guarder checks passing on the current head; its five-minute checks are still running. This review did not execute PR-head code or live-provider tests.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@github-actions

Copy link
Copy Markdown
  1. [P1, merge blocker] Keep accepting the next turn while the previous turn drains. extension.py:463-468 holds the only audio consumer for five seconds after each nonempty finalize. The FIFO holds only five seconds of audio, and reconnect adds at least another 250 ms before it can consume again. With continuous microphone input, on_audio_frame drops the oldest queued frames, potentially removing the start of the next utterance; sending at real-time pace also cannot quickly clear the backlog. The ASR buffering MUST requires an acceptable, session-safe overflow policy. Please decouple the old socket's drain from the next turn, or provide a bounded buffering and catch-up strategy that preserves the next utterance. Add a test that streams continuously through finalize and reconnect and verifies the actual audio delivered over consecutive turns.

  2. [P2, merge blocker] Preserve the provider's handshake error details. When the provider responds with an error handshake, extension.py:151-157 replaces its message with a generic exception; the error reported at lines 182–188 therefore contains ValueError or OSError and a generic message instead of the available native diagnostic. For example, a configuration rejection no longer tells the operator what Prisma rejected. The ASR error contract MUST preserve available native vendor information. Carry the sanitized provider message and any available native code through to vendor_info, and test both fatal rejections and transient capacity errors with a fake handshake.

  3. [P2] Require a final result from the last cycle in the long-duration test. test_long_duration_stream.py:358-365 checks that some final result exists and that any result arrived since the last cycle started. An older final followed by only an interim in the last cycle satisfies both conditions, so the new finalize-end path passes even when the final cycle never produced a final transcript. Track the timestamp or cycle of the last final result and require it to belong to the last cycle; add a regression test with an earlier final and a last-cycle interim.

ASR checklist

  • Lifecycle: pass for the reviewed base lifecycle and shutdown paths.
  • Connection state: pass for the reviewed handshake and explicit-close paths; provider error details fail as described above.
  • Buffering: fail — continuous input overflows during every nonempty finalize and reconnect (finding 1).
  • Finalize: fail — the fixed, unconfirmed drain can lose late transcripts; the documented provider limitation needs evidence for the chosen bound and alternatives under the baseline's SHOULD requirement. The new metadata flag exposes the uncertainty to callers.
  • Reconnect: pass for the reviewed backoff and stop cancellation paths; its interaction with continuous input fails as above.
  • Result shape: pass for the reviewed fields and reported live-test assertions.
  • Metrics: pass for the reviewed finalize-arrival timing; standalone metric coverage remains incomplete.
  • Tests: fail — cover the cases above and the baseline's standalone status/redaction, metrics, dump, and timeline requirements. The PR reports final-head guarder runs still in progress. This review did not execute PR-head code or live-provider tests.

Signed-off-by: Gaurav Chaudhary <chaudharygaurav2004@gmail.com>
@github-actions

Copy link
Copy Markdown
  1. [P1, merge blocker] Keep draining from blocking subsequent short turns. extension.py:531-534 waits for the previous five-second drain inside the only input consumer before committing the current turn. If users finalize several turns less than five seconds apart, each subsequent commit waits for the previous drain and the backlog grows by roughly five seconds per turn. Continuous audio eventually fills the five-second FIFO and the overflow policy drops the beginning of queued speech. The new test streams a six-second second turn, so the first drain has already finished before the second finalize reaches this wait. The ASR buffering MUST requires an acceptable, session-safe overflow policy. Please support closely spaced consecutive turns without stalling input consumption, and test at least three short turns with continuous audio and exact per-socket PCM assertions.

  2. [P2, merge blocker] Flush unsent tail bytes when the connection recovers. extension.py:445-454 removes only the packet whose delivery is ambiguous. If a frame contains multiple packets and that send fails, the remaining bytes stay in self.tail, but the recovery path only sets ready and the consumer waits for a new input. With no later audio or finalize, the successfully reconnected socket never receives those unsent bytes. Wake the consumer and flush the tail after recovery, preserving its session and ordering, and test a multi-packet frame with a failed first send and no subsequent input. The ASR buffering baseline MUST flush buffered audio after recovery even when no new frame arrives.

  3. [P2, merge blocker] Treat a normal close during the handshake as a normal close. extension.py:201-210 catches ConnectionClosedOK from the initial ws.recv() as WebSocketException and emits a NON_FATAL_ERROR. A provider that completes a normal 1000/1001 close before sending its hello therefore produces an ASR error, although the baseline explicitly MUST NOT emit one for ConnectionClosedOK. Handle that exception separately, close the connecting state and retain the retry policy; cover normal and incomplete close handshakes in tests.

  4. [P2, merge blocker] Preserve the base on_data lifecycle contract. extension.py:367-373 never calls super().on_data() for asr_finalize, replacing the base handshake with its own implementation. The ASR guide explicitly requires every overridden on_data to call the base exactly once, including its finalize handling; this bypass ties the plugin to a copy of the current base behavior and omits future framework handling. Please integrate ordered finalize processing with the base contract, or document an intentional framework contract change and migration, and exercise the actual base finalize path in the test.

The five-second unconfirmed drain can still discard a transcript whose first event arrives after the deadline. The PR explains the provider's missing acknowledgement and marks the finalize metadata, but the ASR baseline's final-result-before-finalize SHOULD also requires evidence for the selected bound and alternatives. Please provide that evidence and a delayed-first-result test.

ASR checklist

  • Lifecycle: fail — finalize bypasses the required base on_data call (finding 4).
  • Connection state: fail — a normal handshake close emits an error (finding 3).
  • Buffering: fail — closely spaced turns can overflow, and unsent tail bytes can remain stuck after recovery (findings 1–2).
  • Finalize: fail — the five-second unconfirmed drain needs the documented SHOULD-deviation evidence and delayed-result coverage.
  • Reconnect: fail — buffered tail bytes are not flushed without further input (finding 2).
  • Result shape: pass for the reviewed result fields and metadata construction.
  • Metrics: pass for the reviewed finalize-arrival timestamp handling; standalone metric coverage remains needed.
  • Tests: fail — add the cases above and the baseline's standalone status/redaction, metrics, dump and timeline coverage. The PR reports current-head guarder runs in progress. This review did not execute PR-head code or live-provider tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant