Stream that owns the turn-detector-v1turn-detector-v1-mini (cloud → local) fallback FSM. On cloud transport failure (transport.run() raises, or predictEndOfTurn times out), the stream swaps the transport and rescales per-language thresholds in place on the shared ThresholdOptions, then writes the model swap back to the owning detector so its view stays consistent.

Hierarchy

  • BaseStreamingTurnDetectorStream
    • TurnDetectorStreamImpl

Constructors

Accessors

Methods

  • Drain the shared audio channel into the current transport.

    The audio channel exposes a single ReadableStream (one underlying transform.readable), so only one reader may hold its lock at a time. When signal aborts (a transport being swapped out — e.g. cloud→local fallback — fires it via detach()), we release the reader lock right away: on a pending read() this rejects that read and frees the lock so the swapped-in transport's _drainAudioChannel can re-acquire it. Without this an orphaned drain would hold the lock forever and the next getReader() would throw "ReadableStream is locked".

    Parameters

    • Optional signal: AbortSignal

    Returns Promise<void>

  • Accept a prediction from a transport. A stale response (request id mismatch) is ignored; otherwise the in-flight future resolves with the full TurnDetectionEvent and the request completes.

    Parameters

    • requestId: string
    • probability: number
    • opts: {
          backchannelProbability?: number;
          detectionDelay?: number;
          inferenceDuration?: number;
      } = {}
      • Optional backchannelProbability?: number
      • Optional detectionDelay?: number
      • Optional inferenceDuration?: number

    Returns void

  • Parameters

    Returns Promise<undefined | number>

  • Close the current inference request (new speech, turn boundary, prediction timeout, mode change) and fall back if needed.

    Parameters

    • opts: {
          timedOut?: boolean;
      } = {}
      • Optional timedOut?: boolean

    Returns void

  • Synchronously release this stream's registration on its owning detector, so a replacement stream can be created before this one's async teardown finishes. Base is a no-op; detectors that enforce single-stream ownership override it. Idempotent.

    Returns void

  • Start a new inference request and return its future, superseding any previous request.

    Returns Future<TurnDetectionEvent, Error>

  • Parameters

    Returns Promise<undefined | number>