Repository navigation
Studio: speak through a saved connection on the Audio page - #14288
Conversation
|
That test pins the |
|
@codex review |
1 similar comment
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 381246fc7a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| provider_id: request.providerId, | ||
| model: request.model, | ||
| voice: request.voice, | ||
| speed: request.speed, | ||
| ...(request.instructions ? { instructions: request.instructions } : {}), |
There was a problem hiding this comment.
Forward retained browser-only keys for connection speech
When a connection has no server-saved key because legacy-key migration failed but its key remains in browser storage, this path sends only the provider/model/voice fields. The supported Read Aloud path in studio-speech-synthesis-adapter.ts handles exactly this state by encrypting getExternalProviderApiKey(...) and sending both provider_base_url and encrypted_api_key; AudioRunRequest exposes neither, so _external_tts_speech receives no credential and Audio-page generation fails upstream even though the same saved connection still works for Read Aloud. Carry the legacy credential snapshot through /audio/run (including backend request fields) or reuse that adapter logic.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: a browser-only key exists only until the next provider sync moves it to the server, so this path does not reach a real session.
| }, | ||
| signal?: AbortSignal, | ||
| ): Promise<AudioRunResponse> { | ||
| const response = await authFetch("/api/inference/audio/run", { |
There was a problem hiding this comment.
Revalidate the connection before retrying authentication
When the first POST gets a 401 or a Tauri network retry, authFetch can resend this body, but this call supplies no beforeRetry guard. If Connections is disabled or the same provider is edited while refresh/retry is pending, the backend can still send the prompt through the server-enabled row or its changed URL; generateCustomTtsAudio captures the row and installs assertConnectionSnapshot before every retry specifically to prevent this. Apply the same connection-policy and snapshot check here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: it needs the connection to be disabled or edited inside a single auth refresh window; the next request uses the current row.
| if (busyRef.current === null) setSpeakConnectionId(id); | ||
| return; | ||
| } | ||
| if (modeRef.current === "speak") setSpeakConnectionId(null); |
There was a problem hiding this comment.
Preserve the connection when a busy local pick is ignored
While connection speech is generating, the model picker remains interactive, so choosing a local row executes this clear and then calls handleModelSelect; that function immediately returns when busyRef.current !== null (use-audio-model-slot.ts:917-920). The requested local model is therefore neither queued nor loaded, while the active connection disappears and the UI falls back to the previous local selection after generation. Gate this clear with the same busy check or clear only after the local selection is accepted.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: a local pick made mid-run only drops the connection choice on screen; the running request finishes on the connection and nothing is sent to the wrong place. Re-picking the connection restores it.
| status_code = 400, | ||
| detail = "A saved connection only speaks text, in a voice, with instructions and speed.", | ||
| ) | ||
| speech = await _external_tts_speech( |
There was a problem hiding this comment.
Cancel upstream speech when the run cancel event fires
For a connection-backed /audio/run that supplies cancel_id, posting /audio/cancel only sets _AUDIO_RUN_CANCEL, while this await watches only client disconnect inside _external_tts_speech and never observes _audio_run_event(). If the caller keeps the original request open, potentially paid synthesis runs to completion; only afterward does dispatch notice the flag, delete the newly saved clip, and answer 499, contrary to the cancel endpoint contract. Wire the run event into cancellation of the speech task (and check an already-stashed cancel before starting).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: the cancelled run already returns 499 and discards the clip, and Stop in the UI aborts the upstream call through the disconnect watcher.
| voice: Optional[str] = Field( | ||
| None, max_length = 256, description = "Voice on the connection named by `provider_id`." |
There was a problem hiding this comment.
Reject voice unless a connection provider is selected
This new top-level field is accepted for every AudioRunRequest, but routing enters the connection branch only when provider_id is truthy; otherwise _speak and the other workflows never read body.voice. A local Speak request (or another workflow) with voice now succeeds while silently generating with the default/local voice, whereas the pre-change extra="forbid" behavior rejected that unsupported input. Add cross-field validation requiring provider_id when a non-null voice is supplied, or explicitly implement local voice semantics.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: a stray voice with no connection is ignored and changes nothing.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 480e98ec01
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) | ||
| speech = await _external_tts_speech( | ||
| AudioSpeechRequest( | ||
| input = body.text, |
There was a problem hiding this comment.
Validate empty text before building the speech request
When a provider-backed /audio/run request supplies text: "", it passes AudioRunRequest (whose workflow validator only rejects None) but this in-handler AudioSpeechRequest construction raises an uncaught Pydantic ValidationError because input has min_length=1. FastAPI only converts request-parsing failures to 4xx here, so this accepted input becomes a 500; reject blank text in the outer model/branch or translate the validation error.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: AudioRunRequest._workflow_fields already raises "text must not be empty." for every workflow except convert and separate (studio/backend/models/inference.py), so text: "" is refused with 422 before this handler runs; a test posting it gets 422 and no upstream call.
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Review + reproduction evidencePinned review:
The automated review found no major issues on 5c7807d, and CI is green. I ran Audio > Text to Speech against a self-hosted speaches server (Kokoro-82M, voice af_heart), saved as a Custom connection. The server also serves faster-whisper-tiny. I ran it on the merge base
Conclusion: works end to end and is ready to merge after #14289. Once #14289 lands, merge main in and resolve the 3 audio-page.tsx hunks so both the Transcribe and Speak connection picks are kept. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
# Conflicts: # studio/frontend/src/features/audio/hooks/use-speech-generation.ts
…#14289) Settings > Voice can send dictation to a saved speech-to-text connection, but the Audio page's Transcription tool only offered on-device models. The Transcribe picker now has a Connected section. It lists Whisper, ASR and transcription models from saved connections, OpenAI's whisper-1, gpt-4o-transcribe and gpt-4o-mini-transcribe, and the model set for dictation. Picking one sends the audio to the connection from the server with its saved key, and the transcript streams in and lands in History like a local one. Timestamps asks for line and word times, and is off for the gpt-4o models, which return text only. Speakers stays off, and nothing loads on the device. Audio over 25 MB, OpenAI's limit, is refused with a clear message before anything is sent. Part of #14194 Fixes #14194 ## Before / after Studio built at current main, which already has the Speak connection from #14288 (left), and at this branch's head (right), with a saved custom connection named Scene Speech Box pointing at a local OpenAI-compatible server that lists `kokoro` and `whisper-large-v3`. Transcribe picker: the Connected tab now appears and lists only the speech-to-text model, not the TTS one.  Transcribing an uploaded clip through the connection: one request goes to `/v1/audio/transcriptions`, the transcript shows and lands in History, Speakers is off with its reason, and Use via API is hidden while the connection is picked.  --------- Co-authored-by: Daniel Han <[email protected]>

Settings > Voice can read replies aloud through a saved connection, but the Audio page's Text to Speech tool only offered local models.
The Speak picker now has a Connected section. OpenAI connections offer gpt-4o-mini-tts, tts-1 and tts-1-hd, and self-hosted connections (Kokoro, vLLM, llama.cpp and others) offer the models they list. Picking one sends the text, voice (alloy when empty), style instructions and speed to the connection's /audio/speech with its saved key. The clip lands in Speak's history like a local one, and Stop cancels the call. The load device, saved voices and model options are hidden while a connection is picked.
Picking a local model or turning connections off goes back to local speech.
Part of #14194
Before / after
Studio built at the merge base (left) and at this branch (right), with a saved custom connection named Scene Speech Box pointing at a local OpenAI-compatible server that lists
kokoroandwhisper-large-v3.Text to Speech picker: the Connected tab now appears and lists only the speech model, not the speech-to-text one.
Speaking through the connection: the rail shows the Voice, Style instructions and Speed fields, one request goes to
/v1/audio/speechwith voiceaf_heart, and the clip plays and lands in History.