feat(speech): server-side SpeechAudioProviderInterface with Gemini and ElevenLabs adapters #25

Open
opened 2026-10-27 15:06:22 +00:00 by crapougnax · 0 comments
Owner

Context

@quatrain/speech (#22, PR #23) defines the client-side contracts (SpeechSynthesizerInterface, SpeechController). Server-side text-to-speech providers are still implemented ad hoc by each application, so switching provider means rewriting endpoint code.

Proposal

  • SpeechAudioProviderInterface in @quatrain/speech:
    • id: string
    • synthesize(text: string, options: SpeechOptionsInterface): Promise<{ audio: Uint8Array, mimeType: string }>
    • optional stream(text, options): AsyncIterable<Uint8Array> for providers with chunked output.
  • @quatrain/speech-gemini: Gemini TTS adapter (PCM to WAV wrapping, voice and style prompt mapped from SpeechOptionsInterface).
  • @quatrain/speech-elevenlabs: ElevenLabs adapter (model id, default Flash v2.5; voice id; stability / similarity / style settings; streaming endpoint behind stream()).
  • Fail-fast configuration: API keys and model ids passed by the caller, no environment lookups inside the packages.

Acceptance criteria

  • Both adapters satisfy the interface, with co-located Jest tests using a mocked HTTP layer.
  • READMEs document options, MIME types and latency characteristics.
  • An endpoint can swap provider by changing one constructor call.
## Context `@quatrain/speech` (#22, PR #23) defines the client-side contracts (`SpeechSynthesizerInterface`, `SpeechController`). Server-side text-to-speech providers are still implemented ad hoc by each application, so switching provider means rewriting endpoint code. ## Proposal - `SpeechAudioProviderInterface` in `@quatrain/speech`: - `id: string` - `synthesize(text: string, options: SpeechOptionsInterface): Promise<{ audio: Uint8Array, mimeType: string }>` - optional `stream(text, options): AsyncIterable<Uint8Array>` for providers with chunked output. - `@quatrain/speech-gemini`: Gemini TTS adapter (PCM to WAV wrapping, voice and style prompt mapped from `SpeechOptionsInterface`). - `@quatrain/speech-elevenlabs`: ElevenLabs adapter (model id, default Flash v2.5; voice id; stability / similarity / style settings; streaming endpoint behind `stream()`). - Fail-fast configuration: API keys and model ids passed by the caller, no environment lookups inside the packages. ## Acceptance criteria - Both adapters satisfy the interface, with co-located Jest tests using a mocked HTTP layer. - READMEs document options, MIME types and latency characteristics. - An endpoint can swap provider by changing one constructor call.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quatrain/core#25
No description provided.