Skip to content

feat(tts): text-to-speech toggle, transcript playback, voice samples library - #188

Merged
edenreich merged 16 commits into
mainfrom
fix/issue-186
Sep 4, 2026
Merged

edenreich merged 16 commits into
mainfrom
fix/issue-186

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #186

Summary

Surfaces the infer CLI's existing Text-to-Speech stack in the desktop instead of implementing synthesis here: a Settings toggle writes text_to_speech.enabled through the existing merge_config path, the desktop-owned gateway is spawned with AUDIO_ENABLED=true + AUDIO_LOCAL_AUTO_DOWNLOAD=true only when the toggle is on, generated WAVs render as inline <audio controls> players in the transcript via the Tauri asset protocol, and a new "Voice samples" settings tab manages WAV reference recordings for voice cloning in ~/.infer/models/tts/samples/ (upload via the native file picker, std::fs::copy, preview and delete).

Changes

  • Settings toggle (backend/src/config.rs): DesktopConfig.text_to_speech_enabled reads/writes text_to_speech.enabled (bool round-trip; CLI-managed keys like engine/output_dir in the section pass through untouched, matching the tools.schedule pattern).

  • Gateway env (backend/src/gateway.rs): spawn_gateway now applies audio_env(read_config().text_to_speech_enabled) next to ENABLE_IMAGES=true; env is read at spawn, so toggling takes effect via the existing gateway-restart path (the General tab triggers start_gateway(restart) when the toggle changed on save).

  • Voice samples commands (backend/src/tts_samples.rs, registered in lib.rs): list_voice_samples (non-recursive .wav listing, dir created on first use), add_voice_sample (Rust-side tauri-plugin-dialog blocking_pick_file in spawn_blocking, rejects non-.wav, copies under the base name overwriting duplicates), delete_voice_sample (bare names only; separators/../NUL rejected). No tauri-plugin-fs, no HTML file input.

  • Asset protocol (backend/tauri.conf.json): scope extended with ~/.infer/tts/** (CLI default TTS output dir) and ~/.infer/models/tts/samples/** plus the $HOME/**/.infer/... variants.

  • Frontend (separate commit): safeAudioSrc path guard mirroring safeImageSrc, transcript audio item rendered as <audio controls>, TTS checkbox in General settings, Voice samples tab, API client additions.

  • No synthesis code, model downloads, or audio binaries added — the CLI and gateway own all of it.

  • Voice recording: the Voice samples tab can also record a sample in-app (getUserMedia capture at the native sample rate, encoded with the existing encodeWav, saved via a new save_voice_sample command - name-validated, .wav only).

  • Tooling: infer pinned to v0.189.1, which ships the sample-name resolution fallback ([FEATURE] TextToSpeech: resolve bare sample names against ~/.infer/models/tts/samples/ cli#1174), so cloning by uploaded/recorded sample name works end-to-end.

Follow-up

Cross-repo impact

@inference-gateway-maintainer
inference-gateway-maintainer Bot marked this pull request as ready for review September 2, 2026 00:50
Comment thread backend/tauri.conf.json Resolved
edenreich added a commit to inference-gateway/cli that referenced this pull request Sep 4, 2026
…ple names (#1175)

Resolves #1174

## Summary

`TextToSpeech.resolveSamplePath` now falls back to the desktop voice
samples library (`~/.infer/models/tts/samples/<name>`) when a bare
`voice_sample` name is not found in the working directory, so WAV
samples uploaded through the desktop samples library
(inference-gateway/desktop#188) work end to end without desktop-side
changes. Absolute paths and paths containing separators keep resolving
exactly as before (still rejected by the bare-name guard), and a sample
that resolves nowhere fails with a clear error naming both paths tried.

## Changes

- `internal/agent/tools/text_to_speech.go`: `resolveSamplePath` keeps
the sandbox-validated working-directory lookup as the primary candidate,
then tries `<samples>/<name>`; the new `voiceSamplesDir()` helper
resolves `~/.infer/models/tts/samples` from `os.UserHomeDir()` +
`config.ConfigDirName`, mirroring the TTS models dir default in
`internal/audio/ttsmodel.go`.
- Sandbox validation stays on the working-directory candidate only - the
samples library is a fixed, desktop-managed directory under
`$HOME/.infer` reached only via an already-guarded bare file name.
- A miss on both candidates returns `voice_sample %q not found as a
readable WAV file (tried: <cwd path>, <samples path>)`.
- Updated the `voice_sample` tool parameter description so models know
bare names may reference the samples library.
- Tests: new `TestTextToSpeechTool_SamplePathFallback` (cwd sample takes
precedence, bare name falls back to the samples library, miss errors
naming both paths); pinned `HOME` in `TestTextToSpeechTool_Validate` so
bare-name resolution stays hermetic.

## Checks

- `go test ./internal/agent/tools/`, `task fmt`, `task vet` and the
pre-commit gate (mod tidy, import-alias lint, golangci-lint 0 issues,
markdownlint) all pass.

---------

Co-authored-by: inference-gateway-maintainer[bot] <246577062+inference-gateway-maintainer[bot]@users.noreply.github.com>
Co-authored-by: Eden Reich <[email protected]>
@edenreich
edenreich merged commit 1ddeb53 into main Sep 4, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-186 branch September 4, 2026 15:29
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 0.29.0 🎉

The release is available on GitHub release

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

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Implement text to speech with a voice samples library

1 participant