ttsRuntime (tts/runtime.ts)

pocketpal-ai · src/services/tts/runtime.ts · typescript · MIT
voice

Singleton runtime coordinating TTS engine swaps and playback in React Native.

// Source: https://github.com/a-ghorbani/pocketpal-ai | License: MIT | Copyright 2024 Asghar Ghorbani
// Provided via justclaw.it.com; keep this notice with the code.
import Speech from '@pocketpalai/react-native-speech';

import type {Engine, EngineId} from './types';

/**
 * Single-slot coordinator for the TTS native runtime.
 *
 * The fork's `Speech` module is global — only one neural engine has its
 * model loaded at a time. The previous design tracked initialization
 * per-engine-wrapper, which lied: a wrapper said `initialized=true`
 * even after another engine had silently swapped it out at the native
 * layer.
 *
 * `TTSRuntime` owns the truth ("which engine is currently loaded in
 * native land") and serializes all engine swaps and initialization
 * calls. Engine wrappers route th

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

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

Get a free API key