This page describes speech serve, which serves a synthesis model, a recognition model, a detection model, a
diarization model and an enhancement model over HTTP with a subset of OpenAI's audio API and its Realtime transcription,
holds conversations with a dialogue model over a WebSocket of its own, and has a page on which to try models.
speech serve [MODEL...] [--open] [--host 127.0.0.1] [--port 8080] [--cors-origin ORIGIN|*]...
[--add-voice NAME=FILE]... [--device NAME] [--threads N] [--no-warmup] [request options]
speech serve --open # the page, without a model until one is picked there
speech serve qwen3-tts-0.6b qwen3-asr-0.6b # speech and transcriptions
speech serve reazonspeech-v2 silero-vad # transcriptions, also by the regions where someone speaks
speech serve qwen3-asr-1.7b silero-vad nemotron-3-diarization # and who speaks in each
speech serve qwen3-asr-1.7b silero-vad re-use # transcriptions with noise_reduction, and enhancements
speech serve haru-4b --add-voice me=me.wav # conversations at /v1/dialogue, in the voice of a recording
speech serve irodori-tts-mf --add-voice me=me.voice.gguf --cors-origin http://localhost:5173
speech serve irodori-tts-mf --steps 8 --add-voice me=me.voice.gguf # 8 steps unless a request sets steps
speech serve qwen3-tts-0.6b qwen3-asr-0.6b --language ja --asr.language autoThe server holds at most one model of each task: synthesis, recognition, detection (Silero VAD), whose model
transcriptions with chunking_strategy and Realtime sessions with server_vad use, and diarization (Nemotron 3
Diarization), whose speakers diarized_json and Realtime sessions with diarization give, and enhancement (RE-USE),
which serves /v1/audio/enhancements and cleans the audio of transcriptions and Realtime sessions with
noise_reduction, and dialogue (Haru-4B), which holds conversations at /v1/dialogue. It loads the models given,
listens once they are ready, and logs to stderr.
▁▃▅▇▅▃▁ speech.cpp 0.9.0 · serve
✓ Qwen3-TTS-12Hz-0.6B-CustomVoice synthesis MTL0 1.30 s
✓ Qwen3-ASR-0.6B recognition MTL0 0.27 s
♪ Ready at http://127.0.0.1:8080/
API at http://127.0.0.1:8080/v1; Ctrl-C stops the server
16:59:00 POST /v1/audio/speech 200 voice ryan, seed 8460068737356201: waited 0.000 s, time to first audio 0.045 s, 3.60 s of audio in 0.944 s
16:59:00 GET /v1/nothing 404 Invalid URL (GET /v1/nothing).
Each request is one line: the time, the method and path, the status (gone when the client went away before the
answer, failed when the model failed), what it made or the error's message, and on a server that listens for other
machines the client's address.
| Option | Meaning |
|---|---|
--host ADDRESS |
the address to listen on, 127.0.0.1 unless given. The server has no authentication and no TLS, so a server reachable from other machines belongs behind a proxy that adds them. The page is served only on 127.0.0.1, ::1 or localhost |
--port N |
the port, 8080 unless given, or 0 for any free one |
--open |
open the page in the browser once the server listens; without a MODEL the server starts with none |
--cors-origin ORIGIN |
an origin a web page may call the server from, such as http://localhost:5173, or * for any; repeatable. A web page of any other origin is refused (403 origin_not_allowed); curl and scripts send no origin and are not |
--add-voice NAME=FILE |
add a voice to the synthesis model and to the dialogue model, each that is given, from a voice file or a WAVE file; repeatable |
--device, --threads, --no-warmup |
as for the worker, for the synthesis, recognition, diarization, enhancement and dialogue models the server loads, the page's included. A detection model runs on the CPU with one thread |
a request option, such as --steps 8 or --language ja |
the default of every request that does not set it, for each model given that takes the option. A request's own value wins; an option that no model given takes, or a value out of its range, stops the server before it listens. The detection model's options, such as --threshold, come before OpenAI's server_vad defaults in chunking_strategy and Realtime turn detection |
--tts., --asr., --vad., --diarize., --enhance. or --talk. and a request option, such as --asr.language en |
the same for the synthesis, recognition, detection, diarization, enhancement or dialogue model alone, winning over the option without the prefix. A model the page loads later keeps its own defaults |
| Endpoint | What it does |
|---|---|
GET /health |
answers {"status":"ok"} |
GET /v1/models |
lists the models held, synthesis, recognition, detection, diarization, enhancement and dialogue in that order, as OpenAI's model objects whose id is the model's name, with defaults, the request options the command line gave the model ({} without any), and speech, the model information (c-api.md), which keeps the model's own defaults |
GET /v1/models/{id} |
one model; another id is a 404 (model_not_found) |
POST /v1/audio/speech |
speaks a text, as OpenAI's create speech does |
POST /v1/audio/transcriptions |
recognizes the speech in a WAV file, as OpenAI's create transcription does |
POST /v1/audio/enhancements |
speech.cpp's own: removes noise and other degradations from a WAV file (below) |
GET /v1/realtime |
a WebSocket that transcribes audio as it is sent, as OpenAI's Realtime transcription does (below) |
GET /v1/dialogue |
speech.cpp's own: a WebSocket that holds a conversation with the dialogue model, which listens and speaks at once (below) |
An endpoint of a task the server holds no model of answers a 404 whose message says so. One whose model the page is
replacing answers a 503 (model_loading) with Retry-After.
Each model serves one request at a time, in the order they arrive. A client that disconnects stops its request.
A speech request is a JSON object:
| Member | Meaning |
|---|---|
input |
the text, required |
model |
the synthesis model's id, or left out. Any other model is a 404 (model_not_found) |
voice |
one of the model's voices, required: a Qwen3-TTS speaker or a voice of --add-voice |
response_format |
wav (the default) or pcm. OpenAI's default is mp3, which speech.cpp does not encode; mp3, opus, aac and flac are refused |
stream_format |
audio (the default) or sse, which needs pcm |
speed, instructions |
OpenAI's members, as the options of the same names |
| any other option | every option of the vocabulary by its name (c-api.md), such as language, seed, steps or temperature, which the model checks |
A member speech.cpp does not take is refused rather than ignored, and so is instructions for a model that takes none,
such as Qwen3-TTS 0.6B. A request without seed gets one drawn, which X-Speech-Seed returns; the same request with that
seed gives the same audio on the same device.
Irodori-TTS speaks at most 30 s at a time, so the server speaks an input of several sentences one sentence at a time,
as speech tts does, with the same voice, options and seed, and a pause of 0.9 s between them. A pcm stream sends
the first sentence's audio as soon as it is made. A sentence too long for one request is cut at its commas, or at its
spaces; a run of text with neither that is too long is refused (400, param input). Qwen3-TTS speaks input whole,
up to 24565 tokens.
| Response | What it sends |
|---|---|
wav |
the whole file, 16-bit mono at the model's rate, once the speech is made, with the headers X-Sample-Rate, X-Speech-Seed and X-Speech-Stop (complete, max_seconds or model_limit) |
pcm |
raw 16-bit little-endian mono at the model's rate, Content-Type: audio/pcm, streamed as the model makes it, with X-Sample-Rate and X-Speech-Seed. The headers leave before the speech ends, so they cannot carry the stop reason |
pcm with stream_format: "sse" |
the same PCM as server-sent events: {"type":"speech.audio.delta","audio":"<base64 PCM>"} for each chunk, then {"type":"speech.audio.done","seed":42,"samples":134400,"stop":"complete"}. OpenAI's done event carries the usage in tokens, which speech.cpp does not count |
# A WAV file
curl http://127.0.0.1:8080/v1/audio/speech -H 'Content-Type: application/json' \
-d '{"input": "明日の東京は晴れです。", "voice": "ono_anna"}' -o out.wav
# PCM played as it arrives; the rate is the X-Sample-Rate header (24000 for Qwen3-TTS, 48000 for Irodori-TTS)
curl -sN http://127.0.0.1:8080/v1/audio/speech -H 'Content-Type: application/json' \
-d '{"input": "明日の東京は晴れです。", "voice": "ono_anna", "response_format": "pcm"}' |
ffplay -nodisp -autoexit -f s16le -ar 24000 -ch_layout mono -i -
# On Linux with ALSA: ... | aplay -f S16_LE -r 24000 -c 1
# Server-sent events
curl -N http://127.0.0.1:8080/v1/audio/speech -H 'Content-Type: application/json' \
-d '{"input": "明日の東京は晴れです。", "voice": "ono_anna", "response_format": "pcm", "stream_format": "sse"}'From Python with requests, streaming PCM into a WAV file as it arrives:
import requests
import wave
with requests.post("http://127.0.0.1:8080/v1/audio/speech",
json={"input": "明日の東京は晴れです。", "voice": "ono_anna", "response_format": "pcm"},
stream=True) as r:
r.raise_for_status()
with wave.open("out.wav", "wb") as w:
w.setnchannels(1)
w.setsampwidth(2)
w.setframerate(int(r.headers["X-Sample-Rate"]))
for chunk in r.iter_content(chunk_size=None):
w.writeframes(chunk)A transcription request is a multipart/form-data form, as OpenAI's API takes it. The upload may be up to 25 MB,
OpenAI's limit.
| Member | Meaning |
|---|---|
file |
the audio, required: a WAV file, 16-, 24- or 32-bit PCM or 32-bit float at any rate, its channels averaged and resampled to the model's rate. Any other file is refused with a 400 (param file); convert it first (ffmpeg -i in.mp3 out.wav) |
model |
the recognition model's id, or left out; any other model is a 404 (model_not_found) |
language |
a tag of one of the model's languages, or auto (the default) |
prompt |
what the model is told of the audio before it hears it, for a model that takes it (Qwen3-ASR, Nemotron 3.5 Transcribe) |
keywords[] |
the words or phrases a model that takes them (Haas) listens for and writes as given, a field each, with its readings after "=" (Haas=ハース,ハウス), and no line break (the model's page); verbose_json then has no segments, and a granularity is refused |
keywords_alpha, keywords_guard |
speech.cpp's own: how strongly the keywords are boosted, and whether a change they make is guarded |
response_format |
json (the default), which answers {"text":"..."}; text, the text alone as text/plain; verbose_json (below); or diarized_json, with chunking_strategy each region with its speakers, or from a model that tells who speaks its own segments (below). srt and vtt are refused: speech.cpp gives no subtitles |
timestamp_granularities[] |
segment, word or both, with verbose_json; a model that gives no times refuses it |
decoding |
speech.cpp's own: beam (the default) or greedy, for a model that takes it (reazonspeech-nemo-v2) |
chunking_strategy |
auto, or OpenAI's server_vad object: recognize each region where the detection model finds that someone speaks (below) |
noise_reduction |
speech.cpp's own, under the name of the Realtime session's member: near_field or far_field, both of which enhance the file whole with the enhancement model before chunking_strategy finds its regions and before the recognition; left out, the file is recognized as it is. A server without an enhancement model refuses it (400, param noise_reduction) |
verbose_json answers {"task":"transcribe","language":…,"duration":…,"text":…,"segments":[{"id":0,"start":…,"end":…,"text":…}]}.
duration is the file's length in seconds. language is the tag of the language Qwen3-ASR heard (ja, or ja,en for a
long recording in several), and is left out by a model that names none. segments come from a model that gives times
(FastConformer, Nemotron 3.5 Transcribe), and with the granularity word, words, [{"word":…,"start":…,"end":…}]:
the words of the text, each Japanese or Chinese character a word of its own. Where Nemotron 3.5 Transcribe cannot time
its text, speech.cpp's own untimed says why, and there are neither. Members the recognizers have no value for are
left out.
Every answer carries X-Speech-Stop: complete, or model_limit when the model reached the most tokens it writes or a
loop of them that its guardrail keeps once, with the text written up to there. OpenAI's other members (temperature, stream, include[] and the rest) are refused with
a 400 rather than ignored, known_speaker_names[] and known_speaker_references[] among them.
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@utterance.wav -F response_format=text
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav -F response_format=verbose_json
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav -F language=ja -F prompt="Claude Code、渋谷"
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav -F decoding=greedy # reazonspeech-nemo-v2
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav -F chunking_strategy=auto
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav \
-F 'chunking_strategy[type]=server_vad' -F 'chunking_strategy[silence_duration_ms]=800'
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@street.wav -F noise_reduction=far_field # with re-use heldWith chunking_strategy, the detection model finds where someone speaks in the file, each region is recognized alone,
and the texts are joined in order, with a space between two regions unless either side is Japanese or Chinese text.
segments have the times of the whole file, and language lists the languages heard in order. A file in which no one
speaks gives an empty text. A recognizer given a long stretch with several sentences can drop whole sentences, and write
words where no one speaks; by regions it hears one or a few sentences at a time.
chunking_strategy=auto takes the defaults below. A server_vad object goes as OpenAI's SDKs send it in a form, one
field per member:
| Field | Default | Meaning |
|---|---|---|
chunking_strategy[type] |
server_vad, required with the others |
|
chunking_strategy[threshold] |
0.5 | the speech probability from which audio counts as speech, 0 to 1 |
chunking_strategy[prefix_padding_ms] |
300 | the audio kept before each region's speech, and after it up to silence_duration_ms |
chunking_strategy[silence_duration_ms] |
500 | the silence that ends a region |
A region is at most 10 s long, cut at its longest silence. A silence_duration_ms below about 200 ms cuts sentences at
their pauses, and a stretch of speech shorter than 250 ms between two such cuts is dropped. A request with chunking_strategy to a server without a
detection model is a 400 that says to give it one: speech serve reazonspeech-v2 silero-vad.
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="unused")
with open("meeting.wav", "rb") as f:
print(client.audio.transcriptions.create(model="reazonspeech-nemo-v2", file=f, chunking_strategy="auto").text)With response_format diarized_json and chunking_strategy, the diarization model also finds who speaks when in the
whole file, in its offline mode (sortformer.md), and each region of chunking_strategy is a
segment with the speakers within it:
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav -F response_format=diarized_json -F chunking_strategy=auto{"task":"transcribe","duration":98.012,"text":"...","segments":[
{"type":"transcript.text.segment","id":"seg_0","start":1.396,"end":7.82,"text":"...","speaker":"A",
"speakers":[{"speaker":"A","start":1.66,"end":4.07},{"speaker":"A","start":4.41,"end":7.49}]},
{"type":"transcript.text.segment","id":"seg_1","start":8.276,"end":15.008,"text":"...","speaker":"B",
"speakers":[{"speaker":"B","start":8.53,"end":14},{"speaker":"A","start":14.5,"end":14.65}]}],
"usage":{"type":"duration","seconds":98.012}}Speakers are labeled A, B and on in the order they first speak in the file, as OpenAI labels speakers it does not
know; a label does not name a person. A segment's speaker is the one who speaks the most in its region, or "" where
the diarization finds no one, and speech.cpp's own speakers gives each speaker's parts of the region, in seconds of
the file, two at once where they overlap. Without chunking_strategy the request is a 400 (param
chunking_strategy), and a server without a diarization model answers a 400 that says to give it one.
A recognition model that tells who speaks itself, Nemotron 3.5 Transcribe, answers diarized_json without a
diarization model and without chunking_strategy, which it refuses: it recognizes the whole file with speakers, and
each of its segments, cut where the speaker changes or a sentence ends, carries its speaker, labeled the same way, and
that speaker alone in speakers. Where it cannot time its text, segments is empty and untimed says why.
speech serve nemotron-3.5-transcribe
curl http://127.0.0.1:8080/v1/audio/transcriptions -F file=@meeting.wav -F response_format=diarized_json/v1/realtime speaks OpenAI's Realtime API over a WebSocket, for a transcription session: the client appends audio as
it records it, and the server answers with the text of each utterance, which the client commits itself, or which, with
turn_detection server_vad, the detection model finds. OpenAI's client connects to it by its base URL alone:
import base64
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8080/v1", api_key="unused")
with client.realtime.connect(model="reazonspeech-nemo-v2") as connection:
connection.session.update(session={"type": "transcription", "audio": {"input": {
"format": {"type": "audio/pcm", "rate": 24000}, "transcription": {"language": "ja"}, "turn_detection": None}}})
pcm = open("utterance.raw", "rb").read() # 16-bit little-endian mono PCM at 24000 Hz
connection.input_audio_buffer.append(audio=base64.b64encode(pcm).decode())
connection.input_audio_buffer.commit()
for event in connection:
if event.type == "conversation.item.input_audio_transcription.completed":
print(event.transcript)
breakThe address is ws://127.0.0.1:8080/v1/realtime, with ?model= the recognition model's id or nothing. The
session transcribes with the recognition model held, and starts with turn_detection null: the client commits each
utterance.
| Client event | What it does |
|---|---|
session.update |
sets session.audio.input.transcription: model (the recognition model's id), language, or languages with one tag, prompt, keywords, an array of strings as keywords[] takes them, and speech.cpp's own keywords_alpha and keywords_guard, each left as it was when left out and taken away by null; or null, after which commits are not transcribed. Sets turn_detection: null, or {"type": "server_vad"} with threshold, prefix_padding_ms and silence_duration_ms (below). Sets speech.cpp's own diarization: null, or the diarization model's request options, {} for its defaults (below). Sets noise_reduction: null, or {"type": "near_field"} or {"type": "far_field"}, which need an enhancement model (below). session.type is "transcription", and the format {"type": "audio/pcm", "rate": 24000} |
input_audio_buffer.append |
adds audio, base64 of 16-bit little-endian mono PCM at 24000 Hz |
input_audio_buffer.commit |
transcribes the buffer: what was appended since the last commit or clear |
input_audio_buffer.clear |
drops the buffer |
| Server event | When |
|---|---|
session.created, session.updated |
on connecting, and after each session.update, with the whole configuration |
input_audio_buffer.speech_started |
with server_vad, once speech has begun and lasted long enough to be kept, with audio_start_ms and the item_id of the utterance |
input_audio_buffer.speech_stopped |
with server_vad, once the utterance has ended, with audio_end_ms and its item_id |
input_audio_buffer.committed |
at once for a commit, or with server_vad after speech_stopped, with its item_id and the previous_item_id |
input_audio_buffer.cleared |
for a clear |
conversation.item.input_audio_transcription.delta |
while the utterance goes on: text that adds to the end of what came before (below) |
conversation.item.input_audio_transcription.completed |
once the utterance is recognized whole, with the transcript, the whole text, which replaces the deltas; usage {"type": "duration", "seconds": …}, languages where the model names them (Qwen3-ASR), speech.cpp's own stop, complete or model_limit, and with diarization speech.cpp's own speakers |
conversation.item.input_audio_transcription.failed |
an utterance the model could not transcribe, with OpenAI's error object |
error |
an event the server does not take, with OpenAI's error object and the client's event_id |
While an utterance goes on, the server recognizes it again as audio comes, as often as the model keeps up, and the
deltas carry the beginning that two of these readings in a row agree on. They may stop short of the text, or differ
from it where a later reading changed its mind: a client shows them while someone speaks and replaces them with the
completed transcript, as it does for OpenAI's gpt-live-transcribe. With Qwen3-ASR, each reading and the completed
transcript are given the reading before as their draft, which makes them sooner where the text stays the same.
Utterances are transcribed one after another, each in its turn among the server's other transcriptions, taken when it
is committed. A session holds at most 25 MB of audio not yet transcribed, in its buffer or committed, which is 546 s;
an append past that is an error event (input_audio_buffer_full) and adds nothing. A member or a value
speech.cpp does not take is an error event rather than ignored: a conversation session (session.type: "realtime"),
semantic_vad, the members of server_vad that steer a response (create_response, interrupt_response,
idle_timeout_ms), noise_reduction on a server without an enhancement model, the formats audio/pcmu and audio/pcma and rates other than 24000, include
(log probabilities), delay, more than one language, and every other client event.
With turn_detection server_vad, the detection model finds where someone speaks, as chunking_strategy does in a
file, and each region is an utterance, committed and transcribed as it ends: the same audio gives the same regions and
texts as chunking_strategy with the same values. A server without a detection model answers server_vad with an
error event that says to give it one: speech serve reazonspeech-v2 silero-vad.
| Member | Default | Meaning |
|---|---|---|
threshold |
0.5 | the speech probability from which audio counts as speech, 0 to 1 |
prefix_padding_ms |
300 | the audio kept before each utterance's speech, and after it up to silence_duration_ms |
silence_duration_ms |
500 | the silence that ends an utterance |
An utterance is at most 10 s long, cut at its longest silence. speech_started comes about 0.26 s after the speech
begins, once it has lasted long enough to be kept, and the utterance is committed once silence_duration_ms of
silence has followed it, within the detection's 32 ms. Its audio is all there once the silence has lasted the padding
it keeps after the speech, and the server recognizes it then, so that the completed follows the commit at once where
that recognition takes less than the rest of the silence (200 ms with the defaults); where speech starts again, the
utterance goes on. A shorter silence_duration_ms gives the text sooner, and cuts
sentences at shorter pauses: below about 200 ms, an utterance ends at nearly every pause, and a stretch of speech shorter
than 250 ms between two of them is dropped. The buffer
keeps only the utterance under way, or the last moments of silence, so a session can stay open through silence; a
commit while server_vad runs transcribes it as an utterance, the one that speech_started named if speech is under
way, and a clear drops it, and in both cases turn detection begins again on the audio that follows.
A connection that the server refuses gets an HTTP error before the WebSocket opens: a server without a recognition
model (404, or 503 while the page loads one), a model other than the recognition model held (404), a query member other
than model (400), a web page of an origin --cors-origin does not allow (403),
and, while the server listens on 127.0.0.1, ::1 or localhost, a Host other than those names with the server's port
(403), as for the page. While the page loads another recognition model, a commit fails with model_loading; once it is
loaded, a session that named no model goes on with it, and one that named the previous model, in the address or in
session.update, fails with model_not_found. A session with server_vad lets the detection model go when the page
replaces it, committing the utterance under way, and goes on with the new one.
With diarization in session.update, the diarization model hears the session's audio as it arrives, in its
low_latency mode unless the options say otherwise, and each completed waits until the diarization has settled the
utterance's audio and carries who spoke when within it:
{"type":"conversation.item.input_audio_transcription.completed","item_id":"item_…","transcript":"…",…,
"speakers":[{"speaker":"C","start_ms":24290,"end_ms":28560},{"speaker":"B","start_ms":26970,"end_ms":28150}]}start_ms and end_ms count the session's audio as audio_start_ms does, cut to the utterance, from its
speech_started to its speech_stopped, and two speakers overlap where they speak at once. The diarization settles an
utterance once it has heard about a second of the audio after it (in low_latency), so a client that commits and then
sends nothing gets the completed once more audio comes, silence included, or once it sets diarization to null.
Meanwhile the utterances after it are transcribed, and their completed follow in order. On an Apple M5 with Qwen3-ASR
1.7B (Q8_0) and the diarization model in F16, the completed of an utterance came 1.2 s after its speech ended (p50,
1.3 to 1.5 s at p90), 0.3 s later than without diarization, and the server held 0.2 GB more. Speakers are labeled A,
B and on in the order they first speak in the session, as diarized_json labels them, and each session labels its
own. The options are those of the diarization model, such as {"streaming_mode": "very_low_latency"}, after the
server's --diarize. defaults; one it does not take, or a value out of its range, is an error event with the member
at fault in param. A session.update with the same options keeps the diarization under way and its labels; other
options, or diarization given again after null, start a diarization of the audio that follows, whose speakers take
the labels after those of the diarizations before, since it cannot tell whether someone it hears is one they heard.
null ends it: an utterance committed before then still carries the speakers it found. A server without a diarization
model answers diarization with an error event that says to give it one.
With an enhancement model held, noise_reduction {"type": "near_field"} or {"type": "far_field"} enhances each
utterance whole once it is committed, or once server_vad finds its end, before its completed transcript; both types
run the same model. The turn detection and the deltas hear the audio as it arrives, unenhanced, so the order differs from
OpenAI's, whose noise reduction comes before its turn detection: RE-USE needs a whole chunk of audio, 5 s by default, to
settle any of it, and an utterance whole gives it all of its own audio at once. The enhancement adds its time to each
completion. null, the default, takes it away.
connection.session.update(session={"type": "transcription", "audio": {"input": {
"noise_reduction": {"type": "far_field"}, "turn_detection": {"type": "server_vad"}}}})/v1/dialogue is a WebSocket of speech.cpp's own on which a client talks with the dialogue model: it sends the audio it
hears as it comes, and the model answers each frame of it (133 ms for Haru) with a frame of its own audio and the text
it began to say in it, also while the client speaks. OpenAI's API has no conversation without turns, so OpenAI's
clients do not speak it.
| Client sends | Meaning |
|---|---|
{"type":"start", ...} |
the first message: sample_rate, the rate of the audio it will send, the model's (24000 for Haru) unless given, and the model's request options by name, such as voice, language, seed, speak_first or Haru's character card (name, persona, ...), which speech info lists |
| binary messages | the audio heard, 16-bit little-endian mono PCM at sample_rate, in pieces of any length |
{"type":"hang_up"} |
ends the conversation; the audio short of a frame is dropped |
| Server sends | Meaning |
|---|---|
{"type":"started","sample_rate":24000,"frame_samples":3200} |
the prompt has run; the model's rate and frame |
| binary messages | each frame of the model's audio, 16-bit little-endian mono PCM at the model's rate: the first answers the prompt, and each later one a frame heard |
{"type":"text","text":"..."} |
the text the model began to say in the frame that comes next |
{"type":"end","frames":31,"samples":99200} |
the answer to hang_up, after the last frame; then the server closes |
{"type":"error","error":{...}} |
a failure, as in Errors, such as an option out of range or max_seconds reached; then the server closes |
The server computes each frame once its audio has arrived, and keeps no time: a client that plays the frames as they
come sees whether they keep up, as the page does, which stops a conversation that has fallen a second behind. One
conversation runs at a time; another is refused with a 409 (conversation_in_progress) until it ends, and a client
that goes away ends its own. A conversation holds the memory of its max_seconds from its start (about 1.7 GB for
Haru's 60 minutes), which a lower max_seconds in the start message or as a flag (--max-seconds 600) reduces.
POST /v1/audio/enhancements is speech.cpp's own endpoint, which OpenAI's audio API does not have. Its request is a
multipart/form-data form as a transcription's is, and its answer is audio as a speech's is.
| Member | Meaning |
|---|---|
file |
the audio, required: a WAV file, 16-, 24- or 32-bit PCM or 32-bit float, its channels averaged, at a rate the model takes (8000 to 48000 Hz for RE-USE) unless bwe resamples it |
model |
the enhancement model's id, or left out; any other model is a 404 (model_not_found) |
response_format |
wav (the default) or pcm |
| any other field | an option of the vocabulary by its name, such as chunk_size_in_seconds, hop_length_portion or bwe, its value written as on the command line, which the model checks |
| Response | What it sends |
|---|---|
wav |
the whole file, 16-bit mono at the rate it was enhanced at, the file's own or bwe's, once the audio is enhanced, with X-Sample-Rate and X-Speech-Stop |
pcm |
raw 16-bit little-endian mono at that rate, Content-Type: audio/pcm, streamed as each part of it is settled, a chunk and a hop after its audio, with X-Sample-Rate |
curl http://127.0.0.1:8080/v1/audio/enhancements -F file=@street.wav -o clean.wav
curl http://127.0.0.1:8080/v1/audio/enhancements -F file=@call-8k.wav -F bwe=16000 -o wide.wavA file at a rate the model does not take, or shorter than its STFT (20 ms), is refused with a 400 (param file).
Errors have OpenAI's shape, {"error":{"message":...,"type":...,"param":...,"code":...}}, and param is the input at
fault:
| Category | HTTP | type |
code |
|---|---|---|---|
invalid_argument |
400 | invalid_request_error |
invalid_value |
unsupported |
400 | invalid_request_error |
unsupported_parameter |
out_of_range |
400 | invalid_request_error |
unsupported_value |
model_file, device, out_of_memory, io, internal |
500 | server_error |
the category's name |
So an unknown voice is a 400 unsupported_value with param voice, and a speed on Qwen3-TTS a 400
unsupported_parameter. A member the server does not have is a 400 unknown_parameter.
A refused request gets its error status before any audio. An error while a stream runs ends a pcm stream early, which
the client reads as a broken transfer, and an SSE stream with {"type":"error","error":{...}}.
speech serve --open opens a page on which to try models without writing a request.
- Four tabs: Speak, Transcribe, Live and Talk. At the top of each, a picker lists the catalog's models of its task, each in every type, with their sizes, whether they are fetched and their languages. Picking one fetches it, with progress that can be cancelled and is resumed the next time, and loads it in place of the model of its task. Transcribe and Live use the same recognition model and the same detection model. The options' fields, Live's pause among them, start at the defaults the command line gave a model, and a field left as it is keeps them.
- Speak takes a text and the model's options, plays the speech as the server streams it, and can play it again, save it as a WAVE file or hand it to Transcribe. For Irodori-TTS it makes a voice from a recording dropped on it or recorded in the browser.
- Transcribe takes an audio file in any format the browser decodes, or a recording, and shows the text, the language
heard, the time it took and the segments. A second picker there holds a detection model: with one, the audio is
transcribed by the regions where someone speaks (
chunking_strategy); without one, audio up to a minute is transcribed whole, and longer audio asks for one, since a FastConformer model loses sentences of a long stretch and parakeet's memory grows with the square of its length. - Live transcribes the microphone while you speak, over
/v1/realtimewithserver_vad, so it needs a detection model, which a second picker holds as in Transcribe. The text of an utterance under way is shown in grey and grows as the readings agree; once a pause ends the utterance, its final text replaces it. More options set that pause, 500 ms unless changed. - Talk holds a conversation with the dialogue model through the microphone and the speakers; use headphones, since the model hears what the speakers play. Before it starts, the panel shows the model's options, Haru's character card among them, and makes a voice from a recording, of a speaker whose voice you have the right to use. While it runs, the settings fold away and two lanes show the conversation, you above and the model below, as beads that flow from right to left as each side speaks, with the model's text below them.
- Transcribe sends a file whole, or, where it is larger than the server takes in a request, in pieces of about 12 minutes cut at a pause, whose texts are joined.
- The page is built into
speechand needs nothing from the network.
The server prints the page's address, http://127.0.0.1:8080/. Other web pages cannot use it: the server refuses a
request from another origin than its own, and a Host other than 127.0.0.1, localhost or [::1] with its port. It is
served while the server listens on 127.0.0.1, ::1 or localhost. To use it from another machine, forward the port with SSH, the same number at both
ends (ssh -L 8080:127.0.0.1:8080 host), and open the printed address in your browser. The page loads only models of the catalog,
and removes none; speech rm does.