[Bugfix] Report sample rate and channels for streamed speech PCM (#8567)
Signed-off-by: Yueqian Lin <linyueqian@outlook.com>
This commit is contained in:
1 parent
c32a26a845
commit
1c71a2c03a
8 files changed
+577
-93
No files matched your search
@@ -183,6 +183,16 @@ emit these headers.
|
||||
**Raw audio stream** (`stream_format="audio"`). Streams raw audio bytes (PCM or
|
||||
WAV) as they are decoded.
|
||||
|
||||
`pcm` is 16-bit signed little-endian, interleaved, at the model's native sample
|
||||
rate and channel count (24 kHz mono for most models; MOSS-TTS-Local v1.5 emits
|
||||
48 kHz stereo). Raw streams and non-streaming responses state the format in
|
||||
response headers:
|
||||
|
||||
| Header | Description |
|
||||
| --- | --- |
|
||||
| `x-audio-sample-rate` | Sample rate of the returned audio in Hz (after any `sample_rate` resampling). |
|
||||
| `x-audio-channels` | Channel count of the returned audio. |
|
||||
|
||||
Both streaming modes (`stream_format="audio"` and `"sse"`) require
|
||||
`response_format="pcm"` or `"wav"`, and `speed` must be `1.0` (or omitted).
|
||||
|
||||
@@ -193,9 +203,13 @@ Each event has an `event:` line and a JSON `data:` line:
|
||||
- `speech.audio.delta` — a base64 audio chunk:
|
||||
|
||||
```json
|
||||
{ "type": "speech.audio.delta", "audio": "<base64>", "response_format": "pcm" }
|
||||
{ "type": "speech.audio.delta", "audio": "<base64>", "response_format": "pcm",
|
||||
"sample_rate": 24000, "channels": 1 }
|
||||
```
|
||||
|
||||
`sample_rate` and `channels` extend the OpenAI event and describe the
|
||||
decoded chunk.
|
||||
|
||||
- `speech.audio.done` — terminal event, carrying token `usage`:
|
||||
|
||||
```json
|
||||
@@ -340,7 +354,7 @@ Server -> Client:
|
||||
|
||||
| Message | Description |
|
||||
| --------- | ------------- |
|
||||
| `{"type": "audio.start", "utterance_index": 0, "sentence_index": 0, "sentence_text": "...", "format": "pcm", "sample_rate": 24000}` | Audio generation starting for the buffered input |
|
||||
| `{"type": "audio.start", "utterance_index": 0, "sentence_index": 0, "sentence_text": "...", "format": "pcm", "sample_rate": 24000, "channels": 1}` | Audio generation starting for the buffered input. With `stream_audio=true` it is sent with the first audio chunk, and for `pcm` it carries that audio's `sample_rate` and `channels` (omitted when no audio was produced). |
|
||||
| Binary frame | Raw audio bytes (one or more PCM chunks when `stream_audio=true`) |
|
||||
| `{"type": "audio.done", "utterance_index": 0, "sentence_index": 0, "total_bytes": 96000, "error": false}` | Audio complete for the buffered input |
|
||||
| `{"type": "session.done", "utterance_index": 0, "total_sentences": N}` | Flushed utterance complete |
|
||||
|
||||
Reference in new issue
Block a user