# REST API ## Authentication The base URL is `https://backend.hidoba.com`. Send your quota API key as a bearer token or in the `X-Api-Key` header. Replace the example voice placeholders with IDs supported by your selected model. ```bash curl --fail https://backend.hidoba.com/v2/audio/speech \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model":"ishikawa","voice":"ExampleVoice01","input":"Hello world."}' \ --output speech.mp3 ``` ## Create Speech ```http POST https://backend.hidoba.com/v2/audio/speech Content-Type: application/json ``` ### Request Body | Field | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | `model` | String | Yes | — | `ishikawa`, `matsuo`, or `komahi`. | | `voice` | String | Yes | — | Voice ID for the selected model, up to 255 characters. If the supplied ID includes a folder, send it in full, for example `example-voices/voice-02.wav`. | | `input` | String | Yes | — | Text to synthesize, 1–2,000 characters after trimming surrounding whitespace. | | `language` | String | No | `auto` | Optional language code. Use `auto` or one of the supported short codes below. | | `response_format` | String | No | `mp3` | One of `mp3`, `opus`, `wav`, `pcm`. | | `speed` | Number | No | Model default | Ishikawa accepts `0.5` through `1.5`. Matsuo and Komahi accept `1.0`. | | `excitement` | Number | No | `0` | Matsuo only. A value from `0` through `1` that controls the blend of the voice’s available styles. | Omit `stream` and `stream_format` for this endpoint. For a Matsuo voice with all three styles, `0` uses the normal style, around `0.33` favors whispering, and `1` uses the excited style. A voice’s available styles determine how much the setting changes its sound. ### Language Use the language codes in the table. For English, send `en`. Omitting `language` behaves the same as setting it to `auto`. For Ishikawa, the API detects the language from `input` and passes it to the model when detection is confident and the language is supported. Otherwise, the provider uses its default. Matsuo and Komahi handle automatic language selection within the model. A ✓ indicates that the model accepts the language code. | Code | Language | `ishikawa` | `matsuo` | `komahi` | | --- | --- | :---: | :---: | :---: | | `auto` | Automatic | ✓ | ✓ | ✓ | | `en` | English | ✓ | ✓ | ✓ | | `es` | Spanish | ✓ | — | — | | `fr` | French | ✓ | — | ✓ | | `de` | German | ✓ | — | — | | `it` | Italian | ✓ | — | — | | `pt` | Portuguese | ✓ | — | — | | `pl` | Polish | ✓ | — | — | | `ru` | Russian | ✓ | — | — | | `nl` | Dutch | ✓ | — | — | | `ar` | Arabic | ✓ | — | — | | `zh-cn` | Mandarin Chinese (Simplified) | ✓ | ✓ | — | | `ja` | Japanese | ✓ | — | — | | `ko` | Korean | ✓ | — | — | | `hi` | Hindi | ✓ | — | — | | `he` | Hebrew | ✓ | — | — | ### Example: English MP3 with Matsuo ```bash curl --fail https://backend.hidoba.com/v2/audio/speech \ -H "Authorization: Bearer $HIDOBA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "matsuo", "voice": "girl1", "input": "Hello, this is generated speech.", "language": "en", "response_format": "mp3", "excitement": 0.85 }' \ --output speech.mp3 ``` ### Example: WAV With Language ```bash curl --fail https://backend.hidoba.com/v2/audio/speech \ -H "Authorization: Bearer $HIDOBA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "komahi", "voice": "example-voices/voice-02.wav", "input": "Bonjour, votre commande est prête.", "language": "fr", "response_format": "wav" }' \ --output speech.wav ``` ### Example: Auto Language Detection ```bash curl --fail https://backend.hidoba.com/v2/audio/speech \ -H "Authorization: Bearer $HIDOBA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "ishikawa", "voice": "ExampleVoice01", "input": "Привет! Как дела у тебя сегодня?", "language": "auto", "response_format": "mp3" }' \ --output speech.mp3 ``` ## Response A successful request returns `200 OK` with binary audio. | Format | Content-Type | Audio encoding | | --- | --- | --- | | `mp3` | `audio/mpeg` | MP3 | | `opus` | `audio/ogg` | Opus in an Ogg container | | `wav` | `audio/wav` | PCM in a WAV container | | `pcm` | `application/octet-stream` | Matsuo and Komahi return raw signed 16-bit little-endian PCM at 24 kHz, mono. Ishikawa includes a WAV header. | The response includes a request ID header. ```http X-Hidoba-TTS-Request-Id: 123 ``` Use this ID when asking support to trace a TTS request. Successful synthesis is charged at the selected model’s rate using its reported character count. Counts can vary by model for text containing emoji and other Unicode characters. ## Errors Check the HTTP status before decoding the response as audio. ### Validation Error Invalid request fields return `422`. ```json { "message": "The given data was invalid.", "errors": { "model": ["The selected model is invalid."] } } ``` ### Quota Exhausted An exhausted quota returns `429` with the code `QUOTA_EXHAUSTED`. ```json { "error": "Quota exhausted", "code": "QUOTA_EXHAUSTED" } ``` ### Provider Rejection An invalid provider request can return `422`, including a voice ID the model does not accept. Ishikawa can return `404` for an unavailable voice. ```json { "error": "Invalid TTS request" } ``` ### Temporary Limits The API can return `429` when too many speech requests are in progress. If the quota still has an available balance, reduce concurrency and retry with backoff.