Text-to-speech and speech-to-text
These two one-shot calls turn text into audio and audio into text, and Alfe meters both against your credits. See voice billing for how, and live pricing for rates.
They live under /voice/ rather than /agent/, and take the same agent API key. All
examples use the @alfe.ai/agent-api-client.
Text-to-speech
Section titled “Text-to-speech”const { audio, sampleRate, channels, bitDepth } = await client.tts({ text: "Your report is ready.", // 1 to 5,000 characters voiceId, // optional, from listVoices()});// POST /voice/ttsaudio is a Buffer of raw little-endian PCM samples with no container. The default
framing is 24 kHz, mono, 16-bit. Wrap it in a WAV container to get a playable file.
To pick a voice, call listVoices().
Speech-to-text
Section titled “Speech-to-text”const { text, confidence } = await client.stt({ audio: pcmBytes, // a Uint8Array of raw PCM, up to 10 MiB sampleRate: 16000, // 8000 to 48000});// POST /voice/sttRelated resources
Section titled “Related resources”- Voice overview — live voice sessions and the agent’s voice.
- Your agent’s profile — set the agent’s default voice.