streamingSynthesize (speech/streaming-session.ts)

airi · packages/stage-ui/src/libs/speech/streaming-session.ts · typescript · MIT
voice

Runs a bidirectional streaming TTS session, returning audio and sentence events.

// Source: https://github.com/moeru-ai/airi | License: MIT | Copyright 2024-PRESENT Neko Ayaka
// Provided via justclaw.it.com; keep this notice with the code.
import { getAuthToken } from '../auth'
import { SERVER_URL } from '../server'

/**
 * One control event over the bidirectional streaming TTS protocol
 * (unspeech v1, see `unspeech/docs/wire-protocols/audio-speech-stream-v1.md`).
 *
 * Audio frames travel as raw WebSocket binary frames and never use this
 * envelope.
 */
export interface StreamingTtsServerEvent {
  event:
    | 'session.started'
    | 'sentence.start'
    | 'sentence.end'
    | 'subtitle'
    | 'session.finished'
    | 'error'
  text?: string
  code?: string
  message?: string
  payload?: Record<string, unknown>
}

/**
 * Inbound bookkeeping captured during a sessio

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key