streamSpeech (speech/streaming-pipeline.ts)

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

Creates a streaming TTS pipeline that sends text to a server and emits decoded audio chunks via WebSocket.

// 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 type { SpeechAudio } from '@proj-airi/core-agent'
import type { PcmBlock } from '@proj-airi/pipelines-audio'

import { createPushStream } from '@proj-airi/stream-kit'
import { nanoid } from 'nanoid/non-secure'

import { getAuthToken } from '../auth'
import { SERVER_URL } from '../server'

/**
 * One synthesized sentence emitted by the streaming pipeline. The pipeline
 * delivers these in arrival order; consumers schedule them into their
 * playback manager directly.
 */
export interface StreamingPipelineSentence {
  /** 0-based sentence index within the session. */
  index: number
  /** Sentence text from the upstream `senten

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

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

Get a free API key