xAI (Grok) Text-to-Speech and Speech-to-Text Are Now Available in Puter.js
On this page
Puter.js now supports xAI (Grok) Text-to-Speech and Speech-to-Text, giving developers free access to xAI's voice APIs with expressive voices, inline speech tags, and advanced transcription features like diarization and multichannel support.
Text-to-Speech
xAI TTS offers 5 distinct voices, each with its own character:
- Eve: Energetic, upbeat
- Ara: Warm, friendly
- Rex: Confident, clear
- Sal: Smooth, balanced
- Leo: Authoritative, strong
You can also use inline speech tags like [pause], [laugh], and wrapping tags like <whisper>text</whisper> to add expressive delivery to your audio. Maximum 15,000 characters per request.
Through Puter.js, you get all of this completely free, no registration required, no API keys.
puter.ai.txt2speech("Hello! This is xAI text-to-speech.", {
provider: "xai",
voice: "eve"
}).then(audio => {
audio.play();
});
Speech tags for expressive delivery
const audio = await puter.ai.txt2speech(
"Welcome to Puter! [pause] <whisper>This is a secret.</whisper> [laugh] Just kidding!",
{
provider: "xai",
voice: "ara",
output_format: "mp3"
}
);
audio.play();
Speech-to-Text
xAI STT provides accurate transcription with word-level timestamps, speaker diarization, and multichannel audio support.
const transcript = await puter.ai.speech2txt({
file: "https://assets.puter.site/example.mp3",
provider: "xai",
language: "en",
format: true
});
console.log(transcript.text);
console.log("Duration:", transcript.duration + "s");
Diarization
Enable speaker identification to detect who is speaking at each point in the audio:
const transcript = await puter.ai.speech2txt({
file: "https://assets.puter.site/example.mp3",
provider: "xai",
diarize: true
});
Get Started Now
Just add one library to your project:
// npm install @heyputer/puter.js
import { puter } from '@heyputer/puter.js';
Or add one script tag to your HTML:
<script src="https://js.puter.com/v2/"></script>
No API keys and no infrastructure setup. Start building with xAI TTS and STT immediately.
Learn more:
Free, Serverless AI and Cloud
Start creating powerful web applications with Puter.js in seconds!
Get Started Now