This page describes speech worker, a process that another program starts to speak texts, recognize speech, enhance it
or hold conversations, as ASIST does, and the protocol it speaks.
speech worker MODEL [--add-voice NAME=FILE]... [--device NAME] [--threads N] [--no-warmup] [request options]
speech worker qwen3-tts-0.6b
speech worker irodori-tts-mf --add-voice me=me.voice.gguf --add-voice calm=calm-reference.wav
speech worker irodori-tts-mf --steps 8 --add-voice me=me.voice.gguf
speech worker reazonspeech-v2
speech worker re-useA request option given as a flag (cli.md) is the default of every request that
does not set it, in place of the model's own; a request's own member wins. ready and info list these defaults.
The worker serves one model. It speaks JSON Lines: one JSON object per line on stdin and on stdout, in UTF-8.
- stdout carries the protocol and nothing else; every log goes to stderr. A caller treats a line on stdout that is not a JSON object as a defect of the worker and fails, rather than skipping it.
- Every line in either direction is one JSON object with a string member
type. A member set tonullcounts as left out. A member that the message's type does not have is refused, a name that is not an option included. - Option members take the option's type (c-api.md): a JSON string; an integer without a fraction or
an exponent; any JSON number;
trueorfalse. - Requests run one at a time, in the order they become complete.
infoandcount_tokensonly read the model's information and are answered as they arrive, also while a request runs.
out {"type":"ready","protocol":4,"version":"0.11.2","defaults":{"steps":8},"model":{...model information...}}
out {"type":"fatal","error":{"code":"model_file","option":null,"message":"..."}}
ready comes once the model is loaded, warmed up unless --no-warmup so that a GPU has compiled its kernels before the
first request, and has the voices of --add-voice. version is the release, defaults the request options given as
flags with their values ({} without any), and model is the model information as JSON
(c-api.md), with the device, the threads and the voices added. The model
information keeps the model's own defaults.
fatal comes instead when the worker cannot start. The worker then exits with 1, or with 2 for a command line it cannot
run. A detection or diarization model is unsupported: the worker serves synthesis, recognition, enhancement and dialogue models. A request
option flag the model does not take is unsupported, and a value out of its range out_of_range, each naming the
option.
protocol rises when a caller must change to keep working: a message or member removed, renamed or given another
meaning. A member or message added, an option added to the vocabulary, or a member added to the model information does
not raise it.
type |
Members | Task | Answer |
|---|---|---|---|
synthesize |
id, text, option members |
synthesis | progress and chunks, then one terminal message |
chunk |
id, seq, pcm |
recognition, enhancement, dialogue | none of its own; it adds audio to request id |
transcribe |
id, sample_rate, option members |
recognition | progress, then one terminal message |
enhance |
id, sample_rate, option members |
enhancement | progress and chunks, then one terminal message |
dialogue |
id, sample_rate, option members |
dialogue | a chunk for each frame, then one terminal message |
hang_up |
id |
dialogue | none of its own; it ends conversation id after the audio sent |
add_voice |
id, name, path |
models that take voice files | one terminal message |
info |
id |
any | one terminal message, at once |
count_tokens |
id, text |
synthesis | one terminal message, at once |
cancel |
id |
any | none of its own |
idis a non-empty string, unique among the requests that have not had their terminal message.- A recognition request is its
chunklines,seq0, 1, 2 … in order, then itstranscribeline, which makes it complete, and an enhancement request itschunklines, then itsenhanceline. The chunks of several requests may interleave.sample_rateis the rate of the chunks' audio: any rate for a recognition, which the library resamples, and a rate the model takes for an enhancement (8000 to 48000 Hz for RE-USE), unless itsbweresamples it. - A conversation is its
dialogueline, which starts it when its turn comes and sends the model's first frame before any audio, itschunklines,seq0, 1, 2 … in order and of any length, which the model hears as they arrive, also those that arrive while it waits, and itshang_up, which ends it once it has heard the audio sent; the audio short of a frame is dropped.sample_rateis the rate of its chunks, any rate, which the library resamples. A conversation holds the worker until it ends, and the requests after it wait. The worker keeps no time: it sends a frame as soon as it has computed it, and a caller that plays the frames as they come and sends the microphone's audio as it comes sees whether the model keeps up. pcm, in both directions, is base64 of 16-bit little-endian mono samples. Audio from the worker is at the model'ssample_rate, or for an enhancement at the rate it was enhanced at, the request'ssample_rateor itsbwe, each sampleround(clamp(x, −1, 1) × 32767). Audio to the worker is read asx / 32768.pathofadd_voiceis a voice file, or a WAVE file for a model whosevoice_recordingsis true (Irodori-TTS, Haru); Drama 3 takes a voice file alone (models.md).infogives the voices added so far: one sent before anadd_voicehas had itsendmay not list that voice yet.count_tokenscounts a text's tokens as a synthesis counts them againstmax_text_tokens, so that a caller can split a long text before it sends it, also while a synthesis runs.cancelof a request that is collecting chunks or waiting ends it withcancelledat once. A running request stops at the next point where its work can stop and ends withcancelled, a conversation at its next frame;add_voicecannot be stopped once it runs. A cancel of an id that no request in flight has is ignored.- Once a request has had its
errororcancelledwhile it collected chunks, its laterchunklines are dropped up to and including itstranscribeorenhanceline, which frees its id, or until a chunk 0 under its id starts a new request. A caller that cancels need not send thetranscribeorenhance. - Once a conversation has had its
errororcancelledbefore itshang_up, its laterchunklines are dropped up to and including itshang_up, or until adialogueline starts a new conversation under its id.
When stdin closes, the worker answers the requests it has, answers each request still collecting chunks with an error,
since no transcribe or enhance can follow, ends each conversation once it has heard the audio sent, as its hang_up
does, and exits with 0.
out {"type":"chunk","id":"a","seq":0,"pcm":"..."}
out {"type":"chunk","id":"d","seq":12,"pcm":"...","text":"そう"}
out {"type":"progress","id":"r","done":0.42}
out {"type":"end","id":"a","seed":1234,"samples":96000,"stop":"complete"}
out {"type":"end","id":"r","text":"...","stop":"complete","segments":[{"start":0.0,"end":2.48,"text":"..."}],"tokens":[{"start":0.0,"end":0.16,"text":"..."}]}
out {"type":"end","id":"q","text":"...","stop":"complete","languages":["ja"]}
out {"type":"end","id":"d","frames":151,"samples":483200}
out {"type":"end","id":"v"}
out {"type":"end","id":"i","defaults":{"steps":8},"model":{...model information...}}
out {"type":"end","id":"c","tokens":14}
out {"type":"error","id":"a","error":{"code":"out_of_range","option":"speed","message":"..."}}
out {"type":"cancelled","id":"a"}
- Every request gets exactly one terminal message,
end,errororcancelled, and nothing for its id after it. endof a synthesis hasseed(the request's, or the one the library drew),samples(the number sent in its chunks) andstop(complete,max_secondsormodel_limit).endof a recognition hastextandstop(complete, ormodel_limitwhen it reached the most tokens the model writes or a loop of them that the model's guardrail keeps once, with the text written up to there). It haslanguages, the tags of the languages the model heard in the order of the audio, where there are any (Qwen3-ASR),segmentsandtokenswhen the request settimestamps, andsegmentswith each one'sspeaker, a number from 0 or null, when it setspeakers. Where the model cannot time its text (Nemotron 3.5 Transcribe), it hasuntimed, why, and neither.endof an enhancement hassamples(the number sent in its chunks, as many as its audio has at the rate it was enhanced at) andstop(complete).- A conversation sends a
chunkfor each frame of the model's,frame_samplesof the model information at itssample_rate, withtext, what the model began to say in the frame: often empty, a space where it fell silent. Itsendhasframesandsamples, the numbers it sent. One that reaches itsmax_secondsends with anerror,out_of_rangenamingmax_seconds. endofinfohasmodel,endofcount_tokenshastokens, andendofadd_voicehas nothing more.errorhascode(an error category, c-api.md),option(the input it concerns: an option's name,text,audio,id,type,seq,pcm,name,path,sample_rateor another member's name, or null) andmessage.progresscomes for a running request that is passing no chunks, when the library reports progress and at least 1 s has passed since the request's last message.doneis a fraction from 0 to 1. A caller that takes a silent worker for a hung one allows for the longest single step: the encoder of a long recording runs as one (3.7 s for 311 s of audio with reazonspeech-nemo-v2 in F16 on an Apple M5).- A line that names no request it could belong to (not a JSON object, no string
id, acancelor ahang_upwith a member it does not have, a line that starts a request under anidalready in flight, or achunkor ahang_upfor no conversation in flight) gets anerrorwithoutid. - A request of another task is
unsupportedwith the optiontype: asynthesizeto a model of another task, achunkto a synthesis model, whose later lines are dropped, atranscribe, anenhanceor adialogueto a model of another task, and ahang_upto a model of another task, withoutid. A member the type does not have isinvalid_argumentwith that member asoption. Option values are checked by the library's setters when the request runs, so their errors are the C API's.
- Qwen3-TTS passes audio as it makes it, from the first 0.08 s, at 24 kHz. A cancel takes effect at the next chunk.
- Irodori-TTS makes a request's speech at once and passes it as the codec decodes it, at 48 kHz, so a request should
be one sentence: the first audio waits for the whole text. A text it predicts to last over 30 s is cut after its
sentences, or after its commas, or at its spaces, and spoken in pieces as
speech ttsspeaks it, a sentence's end holding 0.9 s of silence; a text with no place to cut is refused, naming it. A cancel takes effect at the next sampler step or piece of audio. - FastConformer recognizes a request's audio at once, and loses whole sentences of a stretch that holds several, so a request should be one utterance. A cancel takes effect before or after the encoder, or during the decoding.
- Qwen3-ASR recognizes up to 1200 s at once, and longer audio in parts. A cancel takes effect within a fraction of a second.
- Haru hears and gives frames of 3,200 samples at 24 kHz, 133 ms. Its start runs the character card and the voice as a prompt before the first frame. A cancel takes effect at the next frame.
- RE-USE enhances a request's audio in chunks of
chunk_size_in_seconds(5 s) that start everyhop_length_portionof a chunk (0.5), and sends each part of it once the chunk after it is done, the rest after the last chunk. A cancel takes effect at the next chunk.
Irodori-TTS speaking a sentence, a recognizer taking a request in two chunks, and Haru in a conversation of two seconds:
in {"type":"synthesize","id":"1","text":"明日の東京は晴れです。","voice":"me","seed":42}
out {"type":"chunk","id":"1","seq":0,"pcm":"..."}
out {"type":"chunk","id":"1","seq":1,"pcm":"..."}
out {"type":"end","id":"1","seed":42,"samples":134400,"stop":"complete"}
in {"type":"chunk","id":"r","seq":0,"pcm":"..."}
in {"type":"chunk","id":"r","seq":1,"pcm":"..."}
in {"type":"transcribe","id":"r","sample_rate":16000}
out {"type":"end","id":"r","text":"群島や湖では必ずしもヨットは必要ありません。","stop":"complete"}
in {"type":"dialogue","id":"d","sample_rate":48000,"language":"ja","name":"ハル","voice":"me"}
out {"type":"chunk","id":"d","seq":0,"pcm":"...","text":""}
in {"type":"chunk","id":"d","seq":0,"pcm":"..."}
out {"type":"chunk","id":"d","seq":1,"pcm":"...","text":""}
...
in {"type":"hang_up","id":"d"}
out {"type":"end","id":"d","frames":16,"samples":51200}
checks/smoke/worker_client.py is a client in Python that checks every line and one terminal message per request.