Use ref_audio to clone a voice from a short reference clip. Passing the audio transcript through ref_text can often improve generated audio quality.
curl https://api.boson.ai/v1/audio/speech \ -H "Authorization: Bearer $BOSON_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "higgs-tts-3", "input": "Hello, this is a test.", "ref_audio": "https://docs.boson.ai/public/audio/sample.mp3", "ref_text": "Same voice, same words, and uh, a completely different presence. I was built for chat native voice, real-time, expressive, and controllable." }' \ --output out.mp3
import osimport requestsresp = requests.post( "https://api.boson.ai/v1/audio/speech", headers={"Authorization": f"Bearer {os.environ['BOSON_API_KEY']}"}, json={ "model": "higgs-tts-3", "input": "Hello, this is a test.", "ref_audio": "https://docs.boson.ai/public/audio/sample.mp3", "ref_text": "Same voice, same words, and uh, a completely different presence. I was built for chat native voice, real-time, expressive, and controllable.", },)resp.raise_for_status()with open("out.mp3", "wb") as f: f.write(resp.content)
import { writeFile } from "node:fs/promises";const res = await fetch("https://api.boson.ai/v1/audio/speech", { method: "POST", headers: { Authorization: `Bearer ${process.env.BOSON_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ model: "higgs-tts-3", input: "Hello, this is a test.", ref_audio: "https://docs.boson.ai/public/audio/sample.mp3", ref_text: "Same voice, same words, and uh, a completely different presence. I was built for chat native voice, real-time, expressive, and controllable.", }),});await writeFile("out.mp3", Buffer.from(await res.arrayBuffer()));
To clone from a local file, either encode local file as base64 string or send as `multipart/form-data. Below code shows the latter.
curl https://api.boson.ai/v1/audio/speech \ -H "Authorization: Bearer $BOSON_API_KEY" \ -F model=higgs-tts-3 \ -F input="Hello, this is a test." \ -F[email protected] \ -F ref_text="Transcript of the reference clip." \ --output out.mp3
import osimport requestswith open("voice.wav", "rb") as ref_audio: resp = requests.post( "https://api.boson.ai/v1/audio/speech", headers={"Authorization": f"Bearer {os.environ['BOSON_API_KEY']}"}, data={ "model": "higgs-tts-3", "input": "Hello, this is a test.", "ref_text": "Transcript of the reference clip.", }, files={"ref_audio": ref_audio}, )resp.raise_for_status()with open("out.mp3", "wb") as f: f.write(resp.content)
import { readFile, writeFile } from "node:fs/promises";const form = new FormData();form.set("model", "higgs-tts-3");form.set("input", "Hello, this is a test.");form.set("ref_text", "Transcript of the reference clip.");form.set("ref_audio", new Blob([await readFile("voice.wav")]), "voice.wav");const res = await fetch("https://api.boson.ai/v1/audio/speech", { method: "POST", headers: { Authorization: `Bearer ${process.env.BOSON_API_KEY}`, }, body: form,});await writeFile("out.mp3", Buffer.from(await res.arrayBuffer()));
You must own the right to clone the voice.
See Voices for best practices and reusable custom voices.
Inline tags control emotion, style, prosody, and sound effects in the generated audio. Add them to input, and the model adjusts the surrounding speech. For example:
Sample input
Sample audio
<|emotion:enthusiasm|>Welcome to the show! <|prosody:pause|>Let's get started!