Repository navigation
feat(tools): add TextToSFX tool for text-to-sound-effect generation - #1268
Merged
Merged
Conversation
Adds a TextToSFX tool behind text_to_sfx.enabled that turns a text prompt into a short sound-effect or ambience clip through the gateway's SFX API (POST /v1/audio/sfx), the way TextToSpeech produces speech. The domain gains a SoundEffectService port next to SpeechService/MusicService; the gateway implementation calls sdk.Client.CreateSFX and writes the WAV into text_to_sfx.output_dir (default ~/.infer/tmp/sfx). Config mirrors text_to_music: enabled, model (default elevenlabs/eleven_text_to_sound_v2), output_dir and tri-state require_approval; the shared media output_path rule already hoisted by TextToMusic is reused. Enabling the tool also adds to the gateway's AUDIO_ENABLED requirement alongside speech and music.
edenreich
marked this pull request as ready for review
September 22, 2026 18:42
Unit tests mirror the text_to_speech and text_to_music patterns: argument validation (seconds 0.5-30, loop bool, bare output_path), result shape (path, prompt, duration_seconds via audio.WAVDurationSeconds), no partial file on provider failure and registry gating. The infrastructure test exercises sdk.Client.CreateSFX through sdkmocks.FakeClient (request shape, default model, error paths). One integration test pins the mock-gateway behavior, which does not serve /v1/audio/sfx yet. Docs: tools-reference, configuration-reference and directory-structure list the tool and its text_to_sfx knobs.
This was referenced Sep 22, 2026
Closed
tokenless 0.8.0 serves POST /v1/audio/sfx and /v1/audio/music with canned clips, so the TextToSFX and TextToMusic integration tests move from pinning the missing endpoint to the happy path, and new e2e tests drive both tools headless plus the SFX tool through the chat TUI in tmux.
ElevenLabs produces no WAV for sound effects (only mp3, pcm, opus, ulaw, alaw), so the gateway rejected every real TextToSFX call. The tool now asks for mp3, writes sfx-*.mp3, and its prompt and docs say so; the duration_seconds result field goes with the WAV reader. Verified against a live ElevenLabs key. Spec cleanup tracked in inference-gateway/schemas#219, mock parity in inference-gateway/tokenless#65.
Contributor
|
🎉 This PR is included in version 0.206.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1227
Summary
Adds a
TextToSFXtool that turns a text prompt into a short sound-effect or ambience clip (whoosh, click, riser, room tone) through the gateway's SFX API (POST /v1/audio/sfx, SDKCreateSFX), mirroring howTextToSpeechproduces speech andTextToMusiccomposes music. The tool is gated bytext_to_sfx.enabled(default false, hidden when false) and always requests WAV so the desktop video-editing skill can drop the clip on an audio lane.Note on the integration test: the tokenless mock gateway (v0.6.1) does not serve
/v1/audio/sfx, soTestTextToSFXToolAgainstMockGatewaypins the current real behavior (one-line error naming the model, run completes, no partial file) - same approach as the mergedTextToMusictest. The gap is filed against inference-gateway/tokenless#62.Changes
internal/agent/domain: newSoundEffectServiceport next toSpeechService/MusicService(Generate(ctx, prompt, outPath, seconds *float32, loop *bool) error).internal/agent/infrastructure/sfx_service.go: gateway implementation followingspeech_service.go-provider/modelsplit viastrings.Cut,sdk.Client.CreateSFXwithresponse_format: wav, empty-payload guard, writes the file; errors name the configured model.config: top-leveltext_to_sfx:block (enabled,modeldefaultelevenlabs/eleven_text_to_sound_v2,output_dirdefault~/.infer/tmp/sfx, tri-staterequire_approval),provider/modelvalidation when enabled,IsApprovalRequired("TextToSFX")case, andNeedsGatewayAudio()extended so enabling SFX auto-starts the gateway withAUDIO_ENABLED=true.internal/agent/tools/text_to_sfx.go: tool withprompt(required),seconds(0.5-30, optional),loop(optional bool),output_path(bare name; the sharedresolveMediaOutputPathhelper hoisted byTextToMusicis reused, not copied). Result reportspath,prompt,duration_seconds(viaaudio.WAVDurationSeconds) - the same shapeTextToSpeechreports.internal/agent/tools/registry.go(hidden unlesstext_to_sfx.enabledand the service is injected) andinternal/container/container.go; counterfeiter line added tomocks:generate(FakeSoundEffectService).config/prompts.go;INFER_TEXT_TO_SFX_*overrides come free from the reflective env loader.docs/tools-reference.md,docs/configuration-reference.mdanddocs/directory-structure.mdlist the tool and its knobs.Testing
internal/agent/tools/text_to_sfx_test.go(argument validation incl. seconds range, result shape, no-partial-file on failure, registry gating) andinternal/agent/infrastructure/sfx_service_test.go(request shape viasdkmocks.FakeClient, default model, error handling).tests/integration/text_to_sfx_test.goruns the tool against the mock gateway.Follow-ups