Skip to content

feat(tts): add a gateway-backed TextToSpeech engine alongside local llama-tts - #1136

Merged
edenreich merged 8 commits into
mainfrom
feat/tts-gateway-engine
Sep 1, 2026
Merged

edenreich merged 8 commits into
mainfrom
feat/tts-gateway-engine

Conversation

@edenreich

@edenreich edenreich commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #1126. Closes #1137. Adds a gateway-backed synthesis engine to the TextToSpeech tool and makes it the default: text_to_speech.engine: gateway routes synthesis through the gateway's Audio API (POST /v1/audio/speech), with the gateway's built-in local/qwen3-tts as the default model — so TTS works with the auto-started local gateway and zero provider config. llama-tts becomes one backend (engine: qwen3-tts) rather than the only one.

text_to_speech:
  enabled: true
  engine: gateway                 # gateway (default) | qwen3-tts (local/direct)
  model: ""                       # gateway: "" = local/qwen3-tts, or provider/model like openai/gpt-4o-mini-tts
  voice: ""                       # gateway only; provider voice id

Changes

  • SDK v1.35.0 → v1.37.0 — brings CreateSpeech(ctx, provider, CreateSpeechRequest) ([]byte, error) for POST /v1/audio/speech (v1.36.0) plus the schemas v0.27.1 type sync (v1.37.0). The AnthropicMessages adapter and the counterfeiter SDK fake gained the new interface method.
  • Config — engine defaults to gateway (empty means gateway); under it, an empty model resolves to local/qwen3-tts via ResolveGatewayModel(), and a non-empty one must be provider/model (validated with an actionable error). The new voice key selects the provider voice. binary_path, models_dir, ffmpeg_path and the Qwen3 model presets remain qwen3-only.
  • Auto-download follows the engine — text_to_speech.auto_download governs whichever side synthesizes:
    • gateway: the managed gateway is started with AUDIO_ENABLED=true and AUDIO_LOCAL_AUTO_DOWNLOAD=<auto_download> (docker and binary paths), and fetches its own llama-tts binary + GGUFs in a background warmup.
    • qwen3-tts: the CLI auto-downloads the models (as before) and now the llama-tts binary from the inference-gateway/binaries release (sha256-verified) — resolution order binary_path → PATH → ~/.infer/bin cache, same as the gateway.
  • No race on the shared cache — gateway and CLI deliberately share the exact same fixed paths (~/.infer/bin, ~/.infer/models/tts) and identical asset/GGUF filenames. Engine selection makes downloads mutually exclusive in practice, and both sides download via existence-check → temp file in the destination dir → atomic os.Rename, so even a genuine concurrent fetch can only duplicate a download, never corrupt or tear a file the other side picks up.
  • Binary downloader — repointed from the renamed [email protected] release to inference-gateway/binaries latest (also fixes whisper-cli/ffmpeg to track current assets), with .exe asset/cache naming on Windows matching the gateway's cache layout.
  • New backend — internal/agent/infrastructure/speech_service.go mirrors ImageService: requests WAV (so existing .wav output paths and duration reporting are unchanged) and forwards a voice_sample recording as reference_audio for zero-shot voice cloning. Exposed through a new agentdomain.SpeechService port and injected via the container.
  • Registry — selects the backend from engine instead of always constructing audio.NewSynthesizer; gateway engine with no service available means the tool is simply not registered.
  • Docs — docs/text-to-speech.md restructured around both engines (gateway-first, shared-cache and warmup/Retry-After notes, llama-tts auto-download); docs/tools-reference.md and README rows updated.

Testing

  • task precommit:run and task test pass.
  • New/updated table-driven tests: gateway speech service (provider/model split, default local/qwen3-tts model, voice, WAV format, reference audio, error paths), config validation (gateway default, empty-model defaulting, bad models still rejected), registry backend selection (including the nil-service case), and resolveBinary auto-download against a stub release server.
  • Manual: a live synthesis run through the auto-started gateway (local/qwen3-tts, first call may 503-retry during warmup) still needs a run on a real machine.

Cross-repo impact

  • inference-gateway/docs — docs follow-up needed: [DOCS] Document the CLI text_to_speech engines (gateway default with local/qwen3-tts, provider/model + voice, AUDIO_ENABLED/AUDIO_LOCAL_AUTO_DOWNLOAD forwarding, local qwen3-tts engine with llama-tts auto-download from inference-gateway/binaries, shared ~/.infer cache semantics).
  • inference-gateway/binaries — consumed (llama-tts, whisper-cli, ffmpeg assets); no changes needed.
  • schemas, sdk, gateway — already shipped; consumed here, no changes needed.

…lama-tts

text_to_speech.engine now accepts 'gateway' next to qwen3-tts (still the
default): synthesis goes through the gateway's Audio API (/v1/audio/speech,
SDK v1.36.0 CreateSpeech), so requests appear in gateway logs and traces.
Under gateway, model is 'provider/model' and the new voice key selects the
provider voice; voice_sample is forwarded as reference_audio for zero-shot
cloning. The CLI-managed gateway starts with ENABLE_AUDIO=true when the
gateway engine is configured.

Closes #1126
@edenreich
edenreich requested a review from a team as a code owner August 31, 2026 16:52
@inference-gateway-maintainer inference-gateway-maintainer Bot moved this to Todo in 2026 Aug 31, 2026
@edenreich
edenreich force-pushed the feat/tts-gateway-engine branch from 2e57371 to c435405 Compare August 31, 2026 21:44
…the engine

- bump inference-gateway/sdk v1.36.0 -> v1.37.0 (types synced with schemas v0.27.1)
- text_to_speech.engine now defaults to gateway; an empty model resolves to
  the gateway's built-in local/qwen3-tts, so TTS works with the auto-started
  local gateway and zero provider config
- auto-download follows the engine: under gateway the CLI forwards
  AUDIO_LOCAL_AUTO_DOWNLOAD so the gateway fetches its own binary and models;
  under qwen3-tts the CLI now auto-downloads llama-tts from the
  inference-gateway/binaries release (sha256-verified) in addition to the GGUFs
- point the binary downloader at the renamed binaries repo (latest release)
  and handle the .exe asset/cache naming on Windows, matching the gateway's
  ~/.infer/bin cache layout; both sides download via temp file + atomic
  rename into the same shared dirs, so concurrent fetches can never corrupt
  the cache
Comment thread internal/audio/synthesizer.go Resolved
…the tool prompt

- when text-to-speech uses the gateway engine and an already-running gateway
  answers 404 on /v1/audio/speech (started before TTS was enabled, or an
  older binary), the manager now restarts it with AUDIO_ENABLED=true instead
  of silently reusing it; the restart path also refreshes a stale binary
- tighten the TextToSpeech prompt and parameter descriptions: voice_sample
  and output_path are bare file names only, the WAV always lands in the
  configured output directory, and a not-ready first call should be retried
…del id

The gateway serves local/qwen3-tts only when the provider query parameter is
absent and the request body keeps the full model id; splitting it into
provider=local caused a 400 Provider-not-found. Real providers still get the
stripped model name.
@edenreich
edenreich merged commit 571e8cf into main Sep 1, 2026
1 check passed
@edenreich
edenreich deleted the feat/tts-gateway-engine branch September 1, 2026 16:44
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.186.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

No open projects
Status: Done

1 participant