curl https://www.samuraiapi.in/v1/audio/speech \
-H "Authorization: Bearer $SAMURAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1-hd",
"voice": "nova",
"input": "The way of the samurai is found in death.",
"speed": 0.9
}' \
--output speech.mp3
from pathlib import Path
response = client.audio.speech.create(
model="tts-1-hd",
voice="nova",
input="The way of the samurai is found in death.",
speed=0.9
)
response.stream_to_file(Path("speech.mp3"))
Binary audio file (MP3)
Content-Type: audio/mpeg
Audio
Create Speech
Convert text to natural-sounding audio. Choose from 6 voices and 5 audio formats.
POST
/
audio
/
speech
curl https://www.samuraiapi.in/v1/audio/speech \
-H "Authorization: Bearer $SAMURAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1-hd",
"voice": "nova",
"input": "The way of the samurai is found in death.",
"speed": 0.9
}' \
--output speech.mp3
from pathlib import Path
response = client.audio.speech.create(
model="tts-1-hd",
voice="nova",
input="The way of the samurai is found in death.",
speed=0.9
)
response.stream_to_file(Path("speech.mp3"))
Binary audio file (MP3)
Content-Type: audio/mpeg
string
required
TTS model.
tts-1 (faster, lower quality) or tts-1-hd (slower, higher fidelity).string
required
Text to convert to speech. Maximum 4096 characters.
string
required
Voice preset. Options:
alloy, echo, fable, onyx, nova, shimmer.alloy— neutral, versatileecho— male, authoritativefable— British accent, storytellingonyx— deep, powerfulnova— female, friendlyshimmer— female, soft
string
default:"mp3"
Audio format. Options:
mp3, opus, aac, flac, wav. Use opus for lowest latency.number
default:"1.0"
Playback speed. Range:
0.25 to 4.0. 1.0 = normal speed.curl https://www.samuraiapi.in/v1/audio/speech \
-H "Authorization: Bearer $SAMURAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1-hd",
"voice": "nova",
"input": "The way of the samurai is found in death.",
"speed": 0.9
}' \
--output speech.mp3
from pathlib import Path
response = client.audio.speech.create(
model="tts-1-hd",
voice="nova",
input="The way of the samurai is found in death.",
speed=0.9
)
response.stream_to_file(Path("speech.mp3"))
Binary audio file (MP3)
Content-Type: audio/mpeg