Node.js SDK

Audio (TTS & STT)

View as Markdown

Audio

Text-to-Speech

client.audio.synthesize sends POST /v1/audio/speech and returns a Uint8Array of raw audio bytes.

1import { MeshAPI } from "meshapi-node-sdk";
2import { writeFileSync } from "fs";
3
4const client = new MeshAPI({ baseUrl: "https://api.meshapi.ai", token: "rsk_..." });
5
6const audio = await client.audio.synthesize({
7 input: "Hello from MeshAPI.",
8 model: "sarvam/bulbul:v2",
9 voice: "meera",
10});
11
12writeFileSync("output.wav", Buffer.from(audio));

SpeechParams fields

FieldTypeNotes
inputstringRequired. Text to synthesize.
modelstringRequired. e.g. "sarvam/bulbul:v2"
voicestring?Voice ID or name
response_formatstring?Audio format, e.g. "wav", "mp3"
speednumber?Playback speed multiplier

Speech-to-Text (Transcription)

client.audio.transcribe sends POST /v1/audio/transcriptions as a multipart upload and returns a TranscriptionResponse.

1import { readFileSync } from "fs";
2
3const fileBytes = readFileSync("audio.wav");
4
5const result = await client.audio.transcribe(
6 fileBytes,
7 { model: "sarvam/saaras:v3" },
8 { filename: "audio.wav" },
9);
10
11console.log(result.text);

TranscriptionParams key fields

FieldTypeNotes
modelstringRequired. e.g. "sarvam/saaras:v3"
language_codestring?Optional. Model-specific language code (e.g. Sarvam expects "en-IN")
diarizeboolean?Enable speaker diarization
num_speakersnumber?Expected number of speakers
timestamps_granularitystring?e.g. "word" for word-level timestamps
tag_audio_eventsboolean?Tag non-speech audio events
additional_formatsstring?Request extra output formats

Transcribe & Translate

client.audio.translate sends POST /v1/audio/transcriptions/translate — it transcribes the audio and translates the transcript to English in one step. Same three-argument shape as transcribe.

1import { readFileSync } from "fs";
2
3const audio = readFileSync("french_audio.mp3");
4
5const result = await client.audio.translate(
6 audio,
7 { model: "sarvam/saaras:v3" },
8 { filename: "french_audio.mp3" },
9);
10
11console.log(result.text);

Translation (to English)

client.audio.translations sends POST /v1/audio/translations — a distinct endpoint that transcribes audio in any language and returns the text translated to English. It takes the same three-argument shape as transcribe and returns a TranscriptionResponse (.text is the English translation).

1import { readFileSync } from "fs";
2
3const audio = readFileSync("french_audio.mp3");
4
5const result = await client.audio.translations(
6 audio,
7 { model: "openai/whisper-large-v3" },
8 { filename: "french_audio.mp3" },
9);
10
11console.log(result.text); // English translation

Use a speech model that supports translation — see the Models list. model is required.

Optional parameters (passed in the second argument object): prompt (context hint), response_format ("json", "text", or "verbose_json"), and temperature (0–2).


List Voices

client.audio.listVoices sends GET /v1/audio/voices.

1const voices = await client.audio.listVoices({ page_size: 10 });
2console.log(voices);

ListVoicesParams fields

FieldTypeNotes
page_sizenumber?Results per page
next_page_tokenstring?Pagination cursor
searchstring?Filter by name
voice_typestring?"standard", "cloned", etc.
categorystring?Voice category filter

Get Voice

client.audio.getVoice sends GET /v1/audio/voices/{voice_id}.

1const voice = await client.audio.getVoice("voice-id");
2console.log(voice);