Skip to content

Studio: add the Edit speech page - #12606

Merged
danielhanchen merged 148 commits into
unslothai:mainfrom
Etherll:feat/studio-audio-edit
Oct 4, 2026
Merged

danielhanchen merged 148 commits into
unslothai:mainfrom
Etherll:feat/studio-audio-edit

Conversation

@Etherll

@Etherll Etherll commented Oct 3, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #12602. Only the commits after ce9807f are new in this PR.

#12602 has since gained one pre-commit.ci autofix commit (ca6a9bd); it merges into this branch without conflicts and will come in with the next sync.

Summary

Adds an Edit page between Clone and Music. You give it a recording of up to 30 s, Studio transcribes it, you fix the transcript so it matches the audio, then change words in a second copy. The edited clip keeps the speaker's voice and the parts you did not change. It works with DotTTS Edit, Vevo2 and FireRedAudio, the three families spike S2 found can edit. FireRedAudio can also change speed and raise pitch.

Changes

Backend (studio/backend):

  • POST /api/inference/audio/run takes workflow: "edit" with inputs.source (an input id or a history clip) and an edit object (mode, markup or instructions, speed, pitch_steps). The validator only accepts edit together with workflow: "edit", and an edit refuses reference and emotion inputs. There is no new route.
  • The route resolves the recording in the caller's account and converts it to 24 kHz mono. Recordings over 30 s get a 400 ("Edit works on recordings up to 30 s. Record or upload a shorter take.") instead of being cut, since a cut recording no longer matches its transcript.
  • The client computes the word diff. New core/inference/audio_edit.py checks that the DotTTS markup or FireRedAudio instructions turn the original transcript into the edited one, and refuses anything else ("The changes do not match the transcript. Check ① and ② again.").
  • EditSpec on AudioCppFamily describes how each family edits:
    • DotTTS: only the Edit package (matched by name) edits. It sends <sub>/<del>/<ins> markup with template_name: "edit" in one /v1/tasks/run call. DotTTS-MF and SOAR still only speak.
    • Vevo2: runs in an s2s session on the editing route with target_text and the optional original reference_text. When Vevo2 was last loaded for Clone, the server restarts in s2s first, and the next Clone run switches it back.
    • FireRedAudio: sends one semantic_edit instruction per change (Replace 'x' with 'y'., Delete 'x'., Insert 'x' before 'y'.), at most 5, chained so each call edits the previous output. S2 found combined instructions unreliable. Delivery uses acoustic_edit with one call for speed and one for pitch. It runs in the same tts session Clone loads, so there is no reload.
  • Cancelling a FireRedAudio chain stops between calls.
  • Each edit saves the output clip with workflow: "edit", a group_id and the edit recipe (mode, change count, original text, options). An uploaded recording is also saved to history as a role: "source" clip for the A/B compare. Responses and history records contain clip URLs only, never server paths.
  • Status and load responses carry audio_edit (style, delivery support, max changes), and audio_workflows includes edit. Clearing history with workflow=edit only clears Edit clips.

Frontend (studio/frontend/src/features/audio):

  • New pages/edit-page.tsx. The rail has the Recording card, "① Check the transcript" (auto-transcribed when a recording is picked), and "② Make your changes" in TranscriptDiffEditor. The editor marks inserted words with an underline and removed words with strikethrough, and shows a change-count badge and a Reset to transcript button.
  • On FireRedAudio, Words | Delivery tabs appear after ①. Delivery has Speed (0.5x to 2x) and Raise pitch (0 to 6 FireRedAudio steps; +3 steps measured about +2.4 semitones). FireRedAudio cannot lower pitch, so the UI does not offer it. Emotion is not shown because none of the three families supports it.
  • edit-adapters.ts turns the diff into each model's request. The tool panel shows "How edits apply" for the loaded model.
  • ABCompare plays the selected edit as Original | Edited in one player. Playback keeps its position when you switch sides. Its bars are drawn from the gallery file URL because the page CSP blocks fetch(blob:).
  • Edit history hides the source clips and lists only edits. "Use text again" on an Edit clip puts its text back into ②.
  • The draft (recording, transcript, edited text, mode, delivery) persists in unsloth_audio_edit_v1.
  • The tour has Edit steps.

UX

Mapping to the audio pages UX checklist (items 1 to 10):

  1. Fast first result. With no capable model loaded, the page offers DotTTS-Edit-GGUF and Vevo2-GGUF as one-click actions next to "Choose a model". The transcript is filled automatically from the recording. The "Change one word" chip selects the last word in ② so you can type over it. A warm DotTTS Edit run took 3.0 s.
  2. No dead ends. Each blocked Generate state gives its reason inline with an action: "Load a model that can edit speech.", "Add a recording to edit." with Add recording, "Change at least one word in ②." with Go to ②, an expired recording with Add it again, and "The loaded model cannot edit speech." with a model choice or open Speak.
  3. Never lose work. The Edit draft persists across page switches and reloads in unsloth_audio_edit_v1. A new recording starts its changes over from its own transcript and does not touch other pages.
  4. Honest progress. Edit uses the shared run footer, phases and Stop. Before a run, the rail says when Vevo2 will reload for editing ("about 1 to 9 s"). Stop on a 5-call FireRedAudio chain returned 499 at 3.56 s, and the next run returned 200.
  5. Results first. A new edit is selected and opens on the Edited side, ready to play (no autoplay). The source clip stays out of the history list. Moving the result card, the ⋯ menu and Send to on the shared output are deferred (see Known gaps).
  6. Input in one move. The Recording card reuses PR 2's AudioSourceInput: drag and drop on the card, file picker, recording, and From history, with a waveform and duration right after the pick.
  7. Keyboard. Mod+Enter runs Edit's Generate from any field. Focus moves to Play Edited after a run, and aria-live announces "New clip ready." and errors. In ABCompare, Original | Edited is a Tab-reachable pill toggle. On the focused bars, Space plays or pauses, the arrows seek 5 s and Home goes to the start.
  8. Calm density. Advanced starts collapsed. Delivery only appears on FireRedAudio, and Advanced never shows options the edit fills itself (template_name, instruction, source_text, target_text). Labels are plain ("Raise pitch", "How edits apply").
  9. Actionable errors. Backend reasons reach the page as-is, for example "FireRedAudio applies at most 5 changes. Make fewer changes, or use DotTTS Edit." and "Delivery changes need FireRedAudio."
  10. Layout integrity. Screenshots cover the rail and stacked layouts, UI size 12 and 20, light and dark, all taken with reduced motion on. The collapsible panels use motion-reduce fallbacks.

An independent UX reviewer went through the screenshots and listed 16 findings (3 major, 9 minor, 4 nit). Fixed here: the per-row "Edited" badge is gone, the change-count badge uses neutral colors, there is one hint under the diff, and Reset moved to the ② header. Also fixed: the "Change one word" chip selects a word, Words | Delivery tabs sit after ① with Delivery titled "② Change the delivery", the speed caveat is inline instead of in a tooltip, and the Vevo2 note is in the rail. The rest are shared PR 1 and PR 2 components and are under Known gaps.

Testing

Frontend, from studio/frontend:

npm test               # 10126 pass, 0 fail (baseline at ce9807fb5: 10075 pass, 1 timing flake)
npm run typecheck      # exit 0
npm run i18n:check     # pass
npm run build          # exit 0
npx biome check <touched files>   # 0 errors in new files and in files that were clean at ce9807fb5; the others keep their existing format findings

The request adapters are covered by a golden fixture (tests/fixtures/audio-edit-requests.json, 7 cases) that the frontend and backend tests both read.

Backend, from studio/backend (the audio test list from PR 2 plus test_gguf_load_cache_reuse.py and test_account_media_isolation.py, including the new test_audio_edit_requests.py and test_audio_edit_route.py):

python -m pytest -n 8 $(ls tests | grep -E '^test_.*audio.*\.py$|test_gguf_tts|test_native_audio|test_gguf_load_cache_reuse|test_account_media_isolation' | sed 's#^#tests/#')
# 1013 passed, 3 skipped (baseline at ce9807fb5 for the audio list: 869 passed, 3 skipped)
ruff check                                # all passed

GPU smoke ran on a separate Studio install from this branch (install.sh --local) on one GPU. The source is a 4.7 s, 24 kHz recording of "Okay, I'm Cemo and what you just heard wasn't a human voice." Every output was transcribed with ASR and compared to the edited text. ASR hears "Cemo" as "Simo" or "Semo" in the source too.

Case Model Run Output ASR matches edit
Replace one word DotTTS Edit 200 (3.0 s) 48 kHz yes
Delete one word DotTTS Edit 200 (3.4 s) 48 kHz first run no ("wasn't the voice"), rerun yes
Insert one word DotTTS Edit 200 (2.9 s) 48 kHz yes
Two replacements DotTTS Edit 200 (1.8 s) 48 kHz yes
Multi-word replacement DotTTS Edit 200 (1.9 s) 48 kHz yes
48 kHz stereo upload DotTTS Edit 200 (2.9 s) 48 kHz yes
Clone, then edit (switch to s2s) Vevo2 200 (6.8 s) 24 kHz yes
Edit without the original transcript Vevo2 200 (0.9 s) 24 kHz yes, with a repeated "what"
Clone again (switch back) Vevo2 200 (9.7 s) 24 kHz yes
Replace one word FireRedAudio 200 (2.4 s) 24 kHz yes
Two replacements, chained FireRedAudio 200 (4.8 s) 24 kHz yes
Delete FireRedAudio 200 (2.2 s) 24 kHz yes
Insert FireRedAudio 200 (3.4 s) 24 kHz yes
Speed 0.5x FireRedAudio 200 (6.6 s) 7.84 s long (source 4.71 s) text unchanged
Speed 1.5x FireRedAudio 200 (2.8 s) 3.2 s long text unchanged
Pitch +3 FireRedAudio 200 (4.1 s) median F0 106 to 125 Hz text unchanged
Speed 1.5x and pitch +3, chained FireRedAudio 200 (5.7 s) 3.2 s, F0 133 Hz text unchanged

Regression and refusal checks:

Case Result
Clone on Vevo2 before and after editing, Clone on FireRedAudio 200, ASR correct; FireRedAudio edits need no reload
Speak on DotTTS Edit 200, ASR correct
Markup that does not match the transcripts 400 "The changes do not match the transcript. Check ① and ② again."
Delivery on DotTTS Edit 400 "Delivery changes need FireRedAudio."
6 changes on FireRedAudio 400 "FireRedAudio applies at most 5 changes. …"
path key in inputs.source 422
60 s recording 400 "Edit works on recordings up to 30 s. …"
Edit on DotTTS-MF 400 "Load a model that can edit speech."
Stop mid-chain on FireRedAudio (5 changes) 499 at 3.56 s, next run 200
Gallery after the smoke 19 edit clips, 2 source clips (one per uploaded recording), no absolute paths

Known gaps

  • AuK stays hidden. It is still marked unsupported in the package list.
  • FireRedAudio pitch only goes up. S2 found negative steps unreliable.
  • No "Send to Edit" item in other pages' clip menus yet; pick the clip under From history on the Recording card instead.
  • Deferred UX review items (shared output and rail from PR 1 and PR 2): result card position, ⋯ menu and Send to on the output, a pending output card while running, the model name on each history row, empty-state cards, the Load model into placement, the header task label, and "reference" wording in the shared AudioSourceInput (the expired card says "This reference expired." on Edit).

Maintainer changes

  • Slimmed the PR: the runtime request preview is removed (the backend builds the /v1/tasks/run bodies; the shared fixture still pins frontend run body against backend calls), edit specs live on the family entries, clone and edit share one run-response builder, and comments are cut to the load-bearing ones. The PR's own diff went from +5875 to about +5000 lines.
  • audiocpp_server stop now waits up to 120 s after SIGKILL. On a busy GPU, switching Vevo2 between Clone and Edit failed the request with "Could not reach an upstream service" because the old server outlived the 10 s wait; after the fix Clone, Edit and Clone again all return 200.
  • A transcript is applied only to the clip it was made from, and a newer clip's transcription replaces one in flight.
  • Only an output clip is shown as a run's result; with none the inline audio plays.
  • Generate is held with "Keep at least one word in ②." when every word is deleted (it was a 422).
  • The audio.cpp umbrella cache row lists the union of every downloaded family's workflows (Studio: add the Clone page, audio inputs and saved voices #12602), so a downloaded DotTTS Edit is no longer hidden from Edit when another family is found first.
  • Synced with Studio: add the Clone page, audio inputs and saved voices #12602 and upstream main; the Max tokens notice from Studio: say so when the Audio page stops speech at Max tokens #12583 is ported into the Speak hook.

GPU check on one B200 (q8_0 GGUFs, shared card), each output transcribed with Whisper large-v3-turbo:

Case Status Output
DotTTS Edit replace / delete / insert 200 text matches the edit in all three
Vevo2 Clone, then Edit (restart to s2s), then Clone 200, 200, 200 edit and clones correct
FireRedAudio replace 200 text matches
FireRedAudio speed 1.5x 200 4.64 s to 3.2 s
FireRedAudio pitch +3 200 median F0 128.6 Hz to 161.1 Hz
Mismatched markup / delivery on DotTTS / 6 FireRed changes / path in source 400 / 400 / 400 / 422 expected messages
Gallery after the run 9 edits, 1 source clip no server paths

UI before and after

Audio workspace opened on ?workflow=edit, no model loaded. BEFORE is #12602's head (5e1ead8) instead of this PR's merge base, since the Clone stack is not on main yet; AFTER is this PR at 360caae.

Edit page before and after

Etherll and others added 8 commits October 2, 2026 23:38
Map each audio.cpp family's existing task to the Audio workflow it serves
(speak, music, transcribe) and report it as audio_workflows on inference
status and cached-model rows. Gallery clips record their workflow, older
clips infer it from audio_type, and DELETE /audio/gallery can scope a clear
to one workflow.

Fix the spec-task fallback stopping at a 'clon' token, so a clone+music or
clone+asr spec is no longer refused as clone-only. Only offer a fallback
family the installed runtime knows (its model_specs, or the pinned tag's
spec list), and name unsupported task tokens in plain words.

Pass the audio runtime's own error text, sanitized, to /audio/generate,
/v1/audio/speech and transcription instead of a generic internal error.
The 3,600-line Audio page becomes a thin host over hooks (model slot, STT
sidecar, transcription, gallery, generation, handoff) and per-workflow
pages, with the moved code unchanged. A Zustand workspace store holds the
current workflow; only the page commits it, the sidebar and deep links ask.

- Sidebar: Images' workflow list is generalised; a pinned Audio row lists
  its workflows inline, and the More flyout gets an Audio submenu. Nav
  defaults are unchanged.
- Handoffs: ?workflow= and ?task= (text-to-audio opens Music), Library
  clips open on their own page, the chat picker passes the workflow.
- Each page lists only models for its task, keeps its own history and
  drafts, and tours its own controls. Clear all clears only that page.
- Today's model-specific fields move into a tool-panel registry unchanged.
- Generate says why it is off and offers the fix, runs from Mod+Enter,
  shows elapsed time, keeps a failed run's reason, and focuses the new clip.

The source-shape tests that read audio-page.tsx now read the split files,
with their assertions unchanged.
POST /api/inference/audio/inputs streams an upload to disk, decodes it with
PyAV and keeps it per account for a day. /audio/voices stores saved voices.
/audio/run clones a voice from an upload, a history clip or a saved voice:
the route resolves ids to account-scoped 24 kHz mono files and hands the
worker paths, never bytes or a path the client chose.

Clone-only audio.cpp families (Qwen3-TTS Base, Chatterbox, CosyVoice3,
IndexTTS2/2.5, FireRedTTS3, FireRedAudio, Vevo2, Confucius4, MioTTS) list on
Clone instead of Speak, with the server task the spike found loads (clon for
Chatterbox, Echo-TTS, Confucius4 and FireRedTTS3 Base). MioTTS downloads and
loads MioCodec beside it. Maya1 needs a voice description, and VibeVoice text
without a speaker label is sent as Speaker 1.
Clone joins Speak, Music and Transcribe. Its rail takes a reference by
upload, recording, history clip or saved voice, drawn with a waveform as
soon as it is picked, then "What's said in the clip" with a Transcribe
button, the text, language and the model's tools: Timbre only (Qwen3 Base),
Emotion (IndexTTS2), Expressiveness (Chatterbox), Mode (CosyVoice3) and
Speed and dialect (F5). Save voice keeps a reference for later; Speak can use
a saved voice on models that both speak and clone.

Tool panels now validate and shape the request on Speak and Music too, a page
shows its last model as not loaded, and Clone offers recommended models in
one click.
Edit speech on DotTTS Edit (markup, one pass), Vevo2 (s2s editing) and
FireRedAudio (one semantic or acoustic instruction per pass, chained).
/audio/run takes the recording by id, refuses sources over 30 s, keeps the
original as a source clip for A/B, and never returns server paths.
Recording, auto-transcribed transcript, word diff editor, Words | Delivery
modes, per-model request preview, and an Original | Edited compare player.
@Etherll
Etherll requested a review from danielhanchen as a code owner October 3, 2026 09:37
@danielhanchen

Copy link
Copy Markdown
Member

The (Python 3.13, rest) red here is the same one as #12602's, carried in with its audio routes (this branch includes #12602's commits; main does not have these routes yet): tests/multi_account/test_alice_bob_matrix.py::test_object_route_factory_completeness lists the per-object /audio/inputs/{input_id} and /audio/voices/{voice_id} routes as missing from the per-account object route matrix. Adding them to the matrix in #12602 and rebasing this branch onto it should clear it here too.

@danielhanchen danielhanchen self-assigned this Oct 3, 2026
danielhanchen and others added 18 commits October 3, 2026 06:57
…model memory

WorkflowBinding, the status audio_workflows field and lastModelByWorkflow had
no reader. The tool panel registry rendered one instruction field through a
generic framework whose request and validation hooks were never called; the
page now renders that field directly from instructionsFieldKind.
The selected clip is a card with its model and age, a waveform player and
the clip menu, which gains Send to. A run in progress shows a pending card
with its phase, elapsed time and Stop. History rows add the model and age.
An unlisted generated clip now stays on the page that made it instead of
showing on the other TTS page and blocking its history. Switching between
Speak and Music passes the same busy gate as a mode switch, so a load in
flight no longer pulls the page back when it finishes.
Brings in unslothai#12600's pre-commit fixes, comment trims and the move of the
instruction fields to components/instructions-fields.tsx.

unslothai#12600 dropped the tool panel registry, WorkflowBinding, the status
audio_workflows field and lastModelByWorkflow because nothing read them.
The Clone page reads all of them, so they come back here with their first
consumer. The registry renders the instruction fields from their new path,
which leaves instructionsFieldKind without a caller; it goes, and the
tool panel tests keep the copy assertions its test made.
# Conflicts:
#	studio/frontend/src/features/audio/route-search.ts
# Conflicts:
#	studio/frontend/src/features/audio/route-search.ts
# Conflicts:
#	studio/frontend/src/features/audio/audio-run-request.ts
#	studio/frontend/tests/audio-run-api.test.ts
# Conflicts:
#	studio/frontend/src/features/audio/audio-run-request.ts
#	studio/frontend/tests/audio-run-api.test.ts
…y speaks=False family, and count only kept inputs toward the byte cap
# Conflicts:
#	studio/backend/core/inference/audio_cpp_models.py
# Conflicts:
#	studio/backend/core/inference/audio_cpp_backend.py
#	studio/backend/core/inference/audio_cpp_models.py
#	studio/backend/core/inference/audio_cpp_server.py
#	studio/backend/core/inference/orchestrator.py
#	studio/backend/core/inference/worker.py
#	studio/backend/models/inference.py
#	studio/backend/routes/inference.py
#	studio/backend/tests/test_pr7699_worker_audio_mirror.py
#	studio/frontend/src/features/audio/audio-page.tsx
#	studio/frontend/src/features/audio/audio-run-request.ts
#	studio/frontend/src/features/audio/hooks/use-clone-generation.ts
#	studio/frontend/src/features/audio/pages/tts-workspace.tsx
#	studio/frontend/src/features/audio/tools/registry.tsx
# Conflicts:
#	studio/backend/core/inference/audio_cpp_models.py
#	studio/backend/core/inference/audio_gallery.py
#	studio/backend/core/inference/audio_workflows.py
#	studio/backend/models/inference.py
#	studio/backend/routes/inference.py
#	studio/backend/tests/test_audio_gallery.py
#	studio/backend/tests/test_audio_workflows.py
#	studio/frontend/src/features/audio/api.ts
#	studio/frontend/src/features/audio/audio-cpp-catalog.ts
#	studio/frontend/src/features/audio/audio-page.tsx
#	studio/frontend/src/features/audio/audio-run-request.ts
#	studio/frontend/src/features/audio/catalog.ts
#	studio/frontend/src/features/audio/hooks/use-audio-gallery.tsx
#	studio/frontend/src/features/audio/hooks/use-clone-generation.ts
#	studio/frontend/src/features/audio/workflows.ts
#	studio/frontend/tests/audio-workflows.test.ts
#	studio/frontend/tests/audio-workspace-split.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants