File size: 1,655 Bytes
5ac5a78 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | # API reference
All URLs below are relative to your Morisyen TTS service URL.
## Health
`GET /health`
```json
{"status": "ok"}
```
This is a service liveness response. It does not confirm model readiness or audio quality.
## Complete synthesis
`POST /synthesize`
Request header: `Content-Type: application/json`.
```json
{"gen_text": "Bonzur! Kouma ou ete zordi?"}
```
`gen_text` is a required, non-empty string. Successful responses contain:
| Field | Meaning |
| --- | --- |
| `audio_base64` | Base64-encoded complete WAV file |
| `content_type` | `audio/wav` |
| `sample_rate` | `8000` Hz |
| `encoding` | `PCM_16` |
| `duration_seconds` | Generated audio duration in seconds |
| `byte_size` | WAV file length in bytes |
Decode `audio_base64` and save the bytes as a `.wav` file. The base64 text is not the audio file itself.
Invalid or missing input returns an HTTP error, commonly `400` or `422`. Synthesis failures return `500`. Authentication and access controls, if configured, depend on your deployment.
## Streaming synthesis
`WS /ws/synthesize`
1. Connect to the WebSocket endpoint.
2. Send one JSON text frame containing `gen_text`.
3. Consume binary frames; each frame is a complete mono PCM16 WAV chunk at 8,000 Hz.
4. Read the final JSON summary and allow the connection to close.
An error is delivered as a JSON frame with an `error` field. Summary fields can vary by service version. Audio duration and request latency are different measurements.
For continuous playback, extract each WAV chunk's PCM frames before appending them to your audio buffer. Use `client.stream(text)` to perform that conversion automatically.
|