Introducing a new way to review your PRs.

Read the announcement

debpalash / voicestudio

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / speech-input

Transcription and dictation

VoiceStudio turns recorded or live microphone audio into usable text for dictation, capture, dubbing, and other clients. The speech-input system selects a suitable recognition path, returns text with timing and language data, and applies safe cleanup and delivery fallbacks without hiding the original result. It is part of the backend API platform and supplies timed speech to media localization.

Speech-input system

Speech input is a shared service boundary rather than one model. Batch clients use an HTTP or job path, while live dictation uses a WebSocket and a desktop or browser delivery path. Both expose the same main transcript concepts so downstream features can reuse text, timing, language, and engine data. The shared engine routing rules decide which local recognition path can serve the host.

The main paths are:

PathPurposeResult
Batch captureConvert an uploaded recording into text for API, CLI, or MCP-style callersText, segments, language, duration, and engine information
Dubbing transcriptionConvert media into timed phrases for translation and speech replacementTimed segments with speaker labels when available
Live captureShow interim text while audio arrivesPartial text followed by a final transcript
Desktop dictationSend committed speech to the app or field where the shortcut was pressedInserted text or a complete clipboard copy

References: backend/…/capture.py• L52-101 backend/…/capture_ws.py• L236-277 backend/…/dub_core.py• L692-716

Transcription modes

Batch transcription

Batch transcription accepts an audio or video input and returns one complete result. Fast capture can omit word timing, while accurate paths keep timing for subtitles, translation, speaker work, and dubbing. The result keeps recognized text separate from timed segments so simple callers do not need to understand the full media structure.

The immediate /transcribe path returns normalized text and segments without creating a job. Fast mode favors low latency. Accurate mode keeps timed segments and can add speaker labels. Reference mode uses an installed recognizer for voice-reference text. Dictation cleanup and optional language-model refinement run after recognition, so callers can choose between spoken wording and text ready for insertion.

The queued batch path is a media workflow rather than a text-only endpoint. It checks the upload type and model readiness before it stores a large input. It then extracts audio, transcribes with timing, assigns approximate speaker turns, and sends the segments through translation and speech generation for each target language. It rejects manifest-like uploads before processing and keeps the selected translation provider with the queued job.

Batch transcription uses a bounded whole-file call. A stalled recognizer returns an actionable timeout instead of waiting forever. The timed-out in-process call remains accounted for until it exits, so an immediate retry does not overlap two native calls on the same device. A batch with no transcript segments fails clearly instead of producing an empty-looking dub. Retries recheck the original input and required model and provider state before queueing the work again.

References: backend/…/capture.py• L52-101 backend/…/capture.py• L303-419 backend/…/batch.py• L251-361 backend/…/batch.py• L771-880 backend/…/batch.py• L922-1014 backend/…/asr_backend.py• L150-250

Live capture

Live capture streams microphone audio to /ws/transcribe or the versioned platform stream and sends partial text as the buffer grows. A session ends with a final message that is the authoritative result. That message can include segments, language, duration, engine, and a final_kind value.

The system supports a container-based browser path and a low-latency PCM path for live dictation models. When the application plays audio during capture, an optional playback reference helps reduce echo before recognition. The input sample rate is bounded before session state is created. If the live model is unavailable, the socket can use the ordinary capture recognizer, although that path may not provide live partials.

Sherpa live sessions use two kinds of final message. An utterance final commits one pause-delimited piece during a session. A summary final combines committed pieces with trailing speech at end of input, so it is the whole-session authority. This lets long dictation commit work before the socket closes while still giving clients one complete result. Dictation finals then pass through deterministic cleanup before optional refinement. The cleanup removes common hesitations and stutters, fixes casing and spacing, and can turn spoken punctuation commands into marks.

This diagram shows how live audio becomes interim text, committed utterances, and one authoritative summary.

flowchart LR
    Mic[Microphone audio] --> Transport[Live capture transport]
    Playback[Playback reference] -. optional echo reduction .-> Transport
    Transport --> Recognizer[Live or capture recognizer]
    Recognizer --> Partial[Partial text]
    Recognizer --> Utterance[Utterance final]
    Utterance --> Summary[Summary final]
    Recognizer --> Summary
    Summary --> Polish[Deterministic cleanup]
    Polish --> Optional[Optional refinement]
    Optional --> Result[Authoritative text result]

References: backend/…/capture_ws.py• L58-73 backend/…/capture_ws.py• L236-327 backend/…/capture_ws.py• L333-417 backend/…/capture_ws.py• L767-911 backend/…/capture_ws.py• L914-1103 backend/…/asr_backend.py• L2145-2196 backend/…/dictation_cleanup.py• L155-246

Desktop dictation

Desktop dictation starts from a global shortcut in the Tauri shell. Toggle mode starts and stops on successive presses. Hold mode records while the shortcut is held. Browser mode exposes the same request through a window event because it cannot control another desktop application. The desktop integration is part of the Electron workspaces experience.

The dictation settings boundary lets the client enable dictation, choose toggle or hold behavior, select a supported Sherpa model, and check readiness without loading or downloading weights. The API accepts a repository name but stores its canonical model ID. A setting change resets the active capture choice before the preference is saved. If the capture service is not ready, the client receives an error instead of a false success.

The same settings boundary accepts a short vocabulary hint for names, jargon, and preferred spellings. Compatible recognizers receive this hint for each transcription. Other recognizers ignore it, and the silent-model recovery path does not use it when it checks whether the model heard speech.

The desktop captures the target window when a session starts and keeps that target for the session. Successful native delivery inserts text into that target. If the platform cannot safely target or activate the window, VoiceStudio copies the complete result instead of guessing. Dictation history keeps recent final results for search, copy, delete, and export.

References: backend/…/dictation.py• L18-22 backend/…/dictation.py• L53-79 backend/…/dictation.py• L130-201 frontend/…/CaptureWidget.jsx• L363-371 frontend/…/CaptureWidget.jsx• L676-804 frontend/…/DesktopCaptureShortcutBridge.jsx• L12-79 frontend/…/Transcriptions.jsx• L1-45 docs/…/dictation.md• L25-63

Speaker diarization

Speaker diarization means assigning parts of one recording to the people who spoke them. In dubbing, these assignments connect source speech to per-speaker tracks, labels, and voice-clone choices. Ordinary dictation does not need this branch.

The preferred path uses the pyannote speaker pipeline. Some recognition engines can return speaker turns directly, which avoids a second speaker pass when an exact speaker count is not required. FunASR can also include speaker IDs with its timed speech ranges. If no reliable speaker source is available, the system marks changes at long silence gaps. This keeps a job moving, but it estimates turns rather than identifying voices.

The standalone file endpoint offers diarization only in accurate mode because speaker assignment needs timed segments. It adds labels to the affected segments and returns the set of speakers. If the speaker pipeline cannot load or run, the endpoint keeps the transcript and reports an error code instead of failing the speech result.

When a segment crosses a speaker boundary, the system can split it at a word boundary before it assigns labels. A requested speaker count is exact only when pyannote handles the request. Engine-provided turns and silence-gap labels report a warning when they cannot guarantee that count.

The speaker path follows this order:

  1. Use suitable speaker turns from the active recognizer.
  2. Use pyannote when an exact count is needed or no inline turns exist.
  3. Use silence gaps as an approximate fallback when model access or execution fails.

References: backend/…/capture.py• L368-418 backend/…/transcript_diarization.py• L17-76 backend/…/dub_core.py• L1262-1500 backend/…/asr_backend.py• L2210-2301 backend/…/segmentation.py• L465-571 backend/…/segmentation.py• L689-714 backend/…/model_manager.py• L3301-3431 backend/…/batch.py• L328-344

Transcript refinement

Transcript refinement runs only after a final result. Dictation first uses a deterministic cleanup pass that removes common hesitations, collapses short English stutters, fixes shouting and punctuation spacing, and preserves language-sensitive words. An optional spoken-punctuation setting maps English commands such as “comma” or “new paragraph” to marks. A second optional local language-model pass can remove filler, apply clear self-corrections, add punctuation, and keep technical terms.

The raw recognized text remains the source result. Batch and live dictation paths apply deterministic cleanup before optional refinement. When the optional pass changes that cleaned text, the response carries refined_text beside text. Clients can use the refined value for insertion while history and integrations retain the raw value. A missing, disabled, slow, or failing language model never blocks final delivery. A spoken separator at the end of a dictation final remains the separator requested by the speaker rather than being changed to a default stop.

References: backend/…/dictation_cleanup.py• L1-29 backend/…/dictation_cleanup.py• L155-246 backend/…/text_polish.py• L55-83 backend/…/refinement.py• L322-410 backend/…/capture.py• L313-335 backend/…/capture_ws.py• L469-505 backend/…/capture_ws.py• L558-582

Model and device fallbacks

Speech recognition uses a registry of engines with different speed, language, timing, and hardware strengths. It includes local Whisper-family engines, smaller CPU or edge engines, dictation-focused engines, an optional crash-isolated engine, and an OpenAI-compatible remote service. Automatic selection is device-aware. An explicitly selected engine is not silently replaced. See Engine routing and model and compute for the shared device and model rules.

General offline transcription follows this order when automatic selection is active:

Host or conditionPreferred pathFallback behavior
Apple SiliconMLX WhisperUse WhisperX, faster-whisper, or PyTorch Whisper if needed
Real ROCmPyTorch WhisperUse the torch-based path rather than a CTranslate2 CUDA path
Other supported hostsWhisperXUse faster-whisper, then PyTorch Whisper
Explicit engine choiceThe selected engineReport its load failure instead of changing engines silently

WhisperX can use forced alignment for tighter word boundaries. If the aligner is not available for a language or device, the result keeps the recognizer's native timing instead of losing the transcript. MLX transcription can use the same alignment path.

Capture and dictation use a separate speed-focused order. A selected Sherpa model is preferred when it is available. Otherwise an already-installed Parakeet model can win on Apple Silicon when the system language is covered. The next choices are MLX Whisper Turbo, faster-whisper, and PyTorch Whisper. Sherpa models run on the CPU by default and use the shared model cache. Starting dictation does not install a large model without user action.

The model availability boundary reports the supported engines, install state, effective device, and load errors. Known missing models produce a typed asr_model_missing result with a download recommendation. Batch enqueue checks this before it stores the upload. Each fallback candidate is checked before it loads, so a broken primary engine cannot cause a different fallback to download weights without consent. Hosted models with restricted licenses must pass their acceptance gate before use, while user-provided local model paths remain local assets.

User-provided local model paths remain local assets during model checks. This includes rooted POSIX paths on Windows, so the system does not mistake a local path for a hosted model ID or ask for registry licence acceptance.

Reference transcription for a voice clip follows the same installed-only policy. It prefers the active offline engine, then an installed capture engine, then other installed local choices. A successful result is cached by the clip's content so repeated voice-generation requests do not repeat the same recognition work. See Voice generation for the speech output side.

The fallback rules protect both result quality and system capacity:

ConditionSystem response
A known ASR model is not installedReturn a typed missing-model result with an install action; batch enqueue rejects the job before saving the upload
A backend's deeper dependency chain is brokenMark it unavailable and let automatic selection try the next engine; keep a pinned choice explicit
The host does not support the selected compute typeTry a lower compute type or a compatible device path
GPU memory is insufficientReduce the compute choice or use CPU before model load when possible
A whole-file call stallsReturn an actionable timeout and keep the in-process native worker accounted for until it exits
Whole-file calls time out repeatedlyRecommend the crash-isolated engine without changing the engine automatically
A selected live model returns silenceVerify speech with an installed capture fallback and demote the silent model on that machine
A live model or runtime is unavailableUse the legacy capture recognizer or report a typed load error
A remote server returns no detailed segmentsKeep the text as one rough segment and do not claim precise timing
A Sherpa cache is incomplete or staleRepair it when possible, then treat the model as not installed if required assets are absent

References: backend/…/asr_backend.py• L45-250 backend/…/asr_backend.py• L2940-3027 backend/…/asr_backend.py• L3076-3127 backend/…/asr_backend.py• L3162-3239 backend/…/asr_backend.py• L4088-4208 backend/…/capture.py• L126-301 backend/…/dictation.py• L82-127 backend/…/batch.py• L796-855 backend/…/batch.py• L947-978

Transcript consumers

The transcript is used by more than dictation. Dubbing consumes timed text and speaker assignments for translation and voice production. Capture history stores final text with language, duration, and segments for later reuse. This shared result shape lets a fast capture engine and a timing-focused dubbing engine serve different needs without changing the downstream concept of a transcript.

Voice creation can use the active speech engine to make a best-effort transcript of a reference clip when the user does not provide one. The content-keyed cache avoids repeating that work for the same clip. For the wider product flows, see Media localization for the media pipeline that consumes diarized transcripts and Voice generation for speech output.

References: frontend/…/Transcriptions.jsx• L29-45 frontend/…/Transcriptions.jsx• L74-125 backend/…/asr_backend.py• L3407-3479 backend/…/segmentation.py• L442-462 backend/…/dub_core.py• L1526-1545

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the HTTP, WebSocket, and SSE result fields aligned. Clients rely on the same distinction between raw text, final text, segments, language, and engine.
  • Keep final_kind handling aligned between the live socket and the desktop widget. An utterance final is incremental delivery. A summary final is the whole-session authority.
  • Keep deterministic dictation cleanup before optional language-model refinement on every dictation final. Keep plain capture and reference transcription on the less invasive polish path.
  • Keep join_dictation_pieces aligned with the client join rule. Newlines and CJK text must not gain unwanted spaces between committed utterances.
  • Keep the dictation model picker, persisted dictation.model_id, vocabulary prompt, model-installed checks, readiness response, and live-session selection aligned. A downloaded model must be the model used on retry.
  • Keep standalone diarization aligned with the timed-segment contract. It is accurate-mode only, and a load or run failure must preserve the transcript while exposing the diarization error.
  • Keep batch enqueue media-type and manifest checks ahead of model and provider work. A rejected upload must not create a job or cause an environment-dependent model error.
  • Keep batch enqueue preflight aligned with the worker. Validate the ASR model, selected voice, translation engine, provider readiness, and provider-specific setup before persisting a large upload. The queued job must keep the provider selected when it was created.
  • Keep the bounded transcription contract aligned across immediate capture and queued batch work. A timeout must not overlap a retry with an in-process native call.
  • Keep media decoding on the validated local-input path. Container support must not reintroduce remote or manifest input handling through an individual ASR engine.
  • Keep speaker-label source information aligned with automatic voice-clone decisions. Silence-gap labels must not be treated as reliable voice identity.
  • Keep model fallback and routing claims aligned with real device capabilities. Apple Silicon and ROCm need engines that can use those devices. CTranslate2 must not be treated as a universal accelerator path. Keep local model path recognition separate from hosted model licence checks on every platform.
  • Keep remote-server result adaptation aligned with the shared segment contract. Plain text must stay visibly less precise than a response with real segment timing.
  • Keep refinement optional. Any new refinement step must preserve polished raw text when the language-model path is unavailable or exceeds its time bound.
  • Keep file-capture silent-model recovery aligned with live recovery. A fallback must use an installed engine and demote the selected model only after the fallback produces speech text.

Important failure modes

TriggerConsequenceGuard
A non-media upload or media-named manifest reaches batch enqueueThe worker could process an invalid source or follow external playlist referencesValidate the media suffix before model checks and reject manifest-like uploads before queueing
No known ASR weights are installedCapture or batch transcription cannot start and a generic backend error would hide the fixPreflight returns a typed missing-model result with a catalog download action; batch enqueue rejects the upload before queueing
A local rooted path is treated as a hosted model IDA valid local model can be refused by licence checks because it has no registry identityRecognise local paths by syntax, including a leading separator on Windows, before hosted-repository mapping
The selected translation provider is not installed or readyA batch job could store a large upload that cannot reach translationValidate the provider before saving the upload and keep that provider with the queued job
A batch upload is copied into one large memory bufferA large video can exhaust backend memory before transcription startsPersist multipart input in bounded chunks
A selected Sherpa model emits no text for speechLive or uploaded capture appears to work while silently losing wordsVerify speech with an installed fallback, then demote the silent model when the fallback confirms words
Dictation finals use generic polish or a universal joinerA requested trailing separator can become a stop, or CJK and line breaks can receive unwanted spacesUse the language-aware dictation cleanup and shared piece-join rules before final delivery
Diarization is requested without accurate timing or its worker times outThe transcript has no speaker labels even though speech recognition succeededRestrict the feature to accurate mode and return a typed diarization error while cleaning up the timed-out worker
A whole-file ASR call exceeds its time limitThe request stops waiting, but the native worker can remain occupied and an overlapping retry can starve the deviceRaise an actionable timeout and account for the abandoned call before reuse
A local engine has a broken transitive dependencyAutomatic selection can fail at load even though a shallow availability check passedRecord the load cause, skip the engine during automatic selection, and keep a pinned choice explicit
A host is reported as CUDA when it uses Metal or ROCmCTranslate2 can take an unsupported path or leave the accelerator unusedDetect the real device family and choose MLX, PyTorch, or CPU as appropriate
Pyannote access is missingSpeaker labels fall back to silence-gap estimates and rapid turns can mergeEmit a warning with the access cause and mark the labels as approximate
A compatible remote server returns plain text onlyDownstream timing work receives one rough segment instead of detailed timingAdapt the response to the shared shape and keep the loss of timing explicit
A refinement endpoint is slow or unavailableFinal delivery could be delayed even though recognition succeededRun refinement as best effort under a hard time bound and keep the polished raw text
The target desktop window cannot be safely activatedText could be inserted into the wrong applicationCopy the complete transcript instead of guessing the target
Batch transcription returns no segmentsThe queued dubbing job cannot produce translated speechMark the job failed with an explicit transcription error

Key files

FileWhy to read it
backend/…/capture.pyDefines the immediate batch speech-to-text contract, capture modes, cleanup, model preflight, diarization, and file-capture fallback.
backend/…/capture_ws.pyDefines live audio transport, partial and final messages, echo-cancel input, and live fallback behavior.
backend/…/dictation.pyDefines the dictation model catalog, readiness check, vocabulary hint, and validated settings boundary.
backend/…/batch.pyShows how queued media jobs validate inputs, preflight setup, extract audio, transcribe into timed segments, assign heuristic speakers, and pass the result into translation and dubbing.
backend/…/asr_backend.pyDefines the common ASR boundary, device-aware selection, local and remote model checks, validated audio decoding, timeout behavior, reference transcription, capture fallback order, and local-path model identity rules.
backend/…/sherpa_dictation.pyDefines the Sherpa model choices, cache readiness, repair, and machine-local silent-model handling.
backend/…/dictation_cleanup.pyDefines language-aware cleanup for dictation finals, spoken punctuation, and safe joining of committed pieces.
backend/…/refinement.pyDefines final-text cleanup and the optional language-model refinement contract.
backend/…/text_polish.pyDefines the simple typed-text polish used outside the full dictation cleanup path.
backend/…/segmentation.pyShows how recognized timing becomes usable segments and how speaker turns map onto them.
backend/…/transcript_diarization.pyDefines the standalone transcript speaker-label contract and its safe fallback when diarization is unavailable.
backend/…/model_manager.pyDefines pyannote loading and the error classes that drive diarization fallback messages.
frontend/…/CaptureWidget.jsxShows how the client joins recording, live results, final delivery, and truthful status reporting.
frontend/…/Transcriptions.jsxShows how final capture results become searchable local history.
docs/…/dictation.mdDocuments user-visible desktop delivery and platform behavior.