mv.speech
Transcribe short audio files and turn text into voice notes. These methods are on mv.speech, where mv is your client (see the Node.js SDK). Each one returns the response object and throws when the API answers with an error.
synthesize()
Section titled “synthesize()”Synthesize a voice note. Speaks up to 2000 characters in a voice from GET /v1/voices and returns an OGG/Opus file (audio/ogg; codecs=opus, mono, 48 kHz) that plays as a WhatsApp voice note. The Audio-Duration-Ms header gives its length and Audio-Source says whether it is speech or test mode’s synthetic tone. Billed per character. With an Idempotency-Key, a retry within 24 hours returns the same file and is not billed again. Test-mode keys get a synthetic tone as long as the speech would be (the same bytes for the same request) and are never billed.
mv.speech.synthesize(body: SpeechSynthesizeData["body"], options?: RequestOptions): Promise<SpeechSynthesizeResponse>POST /speech/synthesis · API reference
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
body.text |
string |
yes | What to say, up to 2000 characters (longer text is refused with 422 text_too_long). Billed per character. |
body.voice_id |
string |
yes | The voice (voice_id from GET /v1/voices, your custom voices included). |
body.format |
"ogg_opus" |
no | The audio format: ogg_opus (the default), mono 48 kHz, playable as a WhatsApp voice note. |
body.language |
string |
no | The language of text (default: Hebrew when the text is in Hebrew script, else English). |
options.headers["MoreVoice-Version"] |
string |
no | The API version to use for this request. Defaults to the version the API key is pinned to. |
options.headers["Idempotency-Key"] |
string |
no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
options |
RequestOptions |
no | idempotencyKey, extra headers and an abort signal: see retries and idempotency. |
Returns
Section titled “Returns”Nothing, on success.
Example
Section titled “Example”import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
const data = await mv.speech.synthesize({ format: "ogg_opus", language: "he", text: "שלום! ההזמנה שלך יצאה היום ותגיע מחר.", voice_id: "Kore",});console.log(data);transcribe()
Section titled “transcribe()”Transcribe an audio file. Transcribes a short audio file, such as a WhatsApp voice note: OGG/Opus, WebM/Opus, WAV, MP3 or MP4/AAC, up to 16 MB and 10 minutes, as multipart/form-data (a file part) or as JSON with the file base64. Billed per started second of audio; audio with no speech (422 no_speech), audio over max_duration_sec (422 audio_too_long) and unsupported files (415 unsupported_audio) are not billed. The audio is processed in memory and not stored. With an Idempotency-Key, a retry within 24 hours returns the first result and is not billed again. Test-mode keys get a fixed sample transcript in the requested language (after the same format and length checks) and are never billed.
mv.speech.transcribe(body: SpeechTranscribeData["body"], options?: RequestOptions): Promise<SpeechTranscribeResponse>POST /speech/transcriptions · API reference
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
body.file |
object |
yes | The audio: OGG/Opus (a WhatsApp voice note), WebM/Opus, WAV, MP3 or MP4/AAC. JSON requests send it base64; multipart/form-data requests send a file part. |
body.language |
string |
no | The language spoken, as a hint (he, en, …). Without it the language is detected among the platform’s default languages. |
body.max_duration_sec |
integer |
no | The longest audio to accept, in seconds (default and maximum 600). Longer audio is refused with 422 audio_too_long and nothing is billed. |
body.purpose |
"voice_note" |
no | What the audio is (voice_note); informational. |
options.headers["MoreVoice-Version"] |
string |
no | The API version to use for this request. Defaults to the version the API key is pinned to. |
options.headers["Idempotency-Key"] |
string |
no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |
options |
RequestOptions |
no | idempotencyKey, extra headers and an abort signal: see retries and idempotency. |
Returns
Section titled “Returns”Transcription:
| Field | Type | Description |
|---|---|---|
id |
string |
This transcription’s ID (prefix stx_); quote it to support. The result is kept only to replay an Idempotency-Key retry (24 hours). |
object |
"speech.transcription" |
Always speech.transcription. |
livemode |
boolean |
true in live mode, false in test mode. |
text |
string |
What was said. |
language |
string | null |
The language of the transcript: the hint when one was sent, else the detected language (null when none was detected). |
duration_sec |
number |
The audio’s length in seconds. Billed per started second. |
Example
Section titled “Example”import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
const transcription = await mv.speech.transcribe({ file: { content_base64: "T2dnUwACAAAAAAAAAAA=", content_type: "audio/ogg", filename: "note.ogg", }, language: "he", max_duration_sec: 180, purpose: "voice_note",});console.log(transcription);