Skip to main content
Arcanflows

Voice API

Text-to-speech synthesis, speech-to-text transcription, and voice model management.

Overview

The Voice API provides text-to-speech (TTS) and speech-to-text (STT) capabilities with multiple backend providers. You can synthesize speech from text, transcribe audio files, manage voice models, and integrate voice directly into agent conversations.

Supported Backends

BackendTypeCostNotes
edge-ttsTTSFreeMicrosoft Edge voices, 400+ voices, many languages
elevenlabsTTSPaidPremium quality, voice cloning, low latency
openai-ttsTTSPaidOpenAI TTS-1 and TTS-1-HD models
whisperSTTFree/PaidOpenAI Whisper for transcription

Text-to-Speech (TTS)

Synthesize Speech (JSON)

Returns synthesized audio as a base64-encoded string in a JSON response.

POST /api/v1/voice/synthesize

Request Body:

FieldTypeRequiredDescription
textstringYesText to synthesize
voicestringNoVoice ID (default: backend-specific)
backendstringNoBackend provider (edge-tts, elevenlabs, openai-tts)
languagestringNoLanguage code (e.g., en-US, es-MX)
speednumberNoPlayback speed multiplier (0.5 - 2.0)
formatstringNoAudio format: mp3, wav, ogg (default: mp3)
bash
curl -X POST /api/v1/voice/synthesize \
  -H "Authorization: Bearer <your_login_jwt>" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, welcome to Arcanflows.",
    "voice": "en-US-AriaNeural",
    "backend": "edge-tts",
    "format": "mp3"
  }'

Response:

json
{
  "audio": "base64_encoded_audio_data...",
  "format": "mp3",
  "duration_ms": 2340,
  "backend": "edge-tts",
  "voice": "en-US-AriaNeural",
  "cached": false
}

Synthesize Speech (Audio File)

Returns the audio file directly as a binary response.

POST /api/v1/voice/synthesize/audio

Same request body as /synthesize. Response is the raw audio file with appropriate Content-Type header (e.g., audio/mpeg).

Routed Synthesis

Auto-selects the best available backend based on voice, cost, and quality settings.

POST /api/v1/voice/synthesize/routed
POST /api/v1/voice/synthesize/audio/routed

Same request body but omit the backend field. The router selects the optimal backend automatically.


Speech-to-Text (STT)

Transcribe Audio

POST /api/v1/voice/transcribe

Request: multipart/form-data

FieldTypeRequiredDescription
audiofileYesAudio file (mp3, wav, ogg, webm, m4a)
languagestringNoLanguage hint (e.g., en, es)
backendstringNoSTT backend (default: whisper)
bash
curl -X POST /api/v1/voice/transcribe \
  -H "Authorization: Bearer <your_login_jwt>" \
  -F "[email protected]" \
  -F "language=en"

Response:

json
{
  "text": "Hello, I need help with my account.",
  "language": "en",
  "duration_ms": 4200,
  "backend": "whisper",
  "confidence": 0.95
}

Routed Transcription

POST /api/v1/voice/transcribe/routed

Auto-selects the best STT backend.


Agent Voice Integration

Send Audio to Agent

Send an audio message to an agent conversation. The audio is transcribed and the agent responds as text.

POST /api/v1/agents/:id/chat/audio

Request: multipart/form-data

FieldTypeRequiredDescription
audiofileYesAudio file to send
conversation_idstringNoExisting conversation ID
bash
curl -X POST /api/v1/agents/agent_abc123/chat/audio \
  -H "Authorization: Bearer <your_login_jwt>" \
  -F "[email protected]" \
  -F "conversation_id=conv_xyz789"

Response:

json
{
  "conversation_id": "conv_xyz789",
  "transcription": "What is my account balance?",
  "response": "Your current account balance is $1,234.56.",
  "message_id": "msg_abc123"
}

Get TTS for Agent Response

Convert an agent's text response to speech.

POST /api/v1/agents/:id/chat/tts

Request Body:

FieldTypeRequiredDescription
message_idstringYesMessage ID to convert
voicestringNoVoice ID override

Response: Audio file binary with Content-Type: audio/mpeg.


Voices and Backends

List Available Voices

GET /api/v1/voice/voices

Query Parameters:

ParameterTypeDescription
backendstringFilter by backend
languagestringFilter by language code
genderstringFilter by gender (male, female)
bash
curl /api/v1/voice/voices?backend=edge-tts&language=en \
  -H "Authorization: Bearer <your_login_jwt>"

Response:

json
{
  "voices": [
    {
      "id": "en-US-AriaNeural",
      "name": "Aria",
      "language": "en-US",
      "gender": "female",
      "backend": "edge-tts",
      "preview_url": "/api/v1/voice/voices/en-US-AriaNeural/preview"
    },
    {
      "id": "en-US-GuyNeural",
      "name": "Guy",
      "language": "en-US",
      "gender": "male",
      "backend": "edge-tts",
      "preview_url": "/api/v1/voice/voices/en-US-GuyNeural/preview"
    }
  ],
  "total": 2
}

List Voice Backends

GET /api/v1/voice/backends

Returns all configured voice backends and their status.

Voice Service Health

GET /api/v1/voice/health

Returns the health and availability of each voice backend.


TTS Model Management

For self-hosted TTS backends, you can manage installed models.

List All TTS Models

GET /api/v1/voice/tts/models

Returns all available TTS models (installed and remote).

List Installed Models

GET /api/v1/voice/tts/models/installed

Returns only locally installed TTS models.

GET /api/v1/voice/tts/models/recommended

Returns a curated list of recommended models by quality and language.

Download Model

POST /api/v1/voice/tts/models/download

Request Body:

json
{
  "model_name": "tts-piper-en-us-amy-medium"
}

Load Model

POST /api/v1/voice/tts/models/load

Request Body:

json
{
  "model_name": "tts-piper-en-us-amy-medium"
}

Delete Model

DELETE /api/v1/voice/tts/models/:model_name

Removes an installed model from disk.


Cache Management

Invalidate Cache

Clear cached TTS audio files.

POST /api/v1/voice/cache/invalidate

Request Body:

FieldTypeRequiredDescription
backendstringNoClear cache for specific backend only
voicestringNoClear cache for specific voice only
allbooleanNoClear entire cache
bash
curl -X POST /api/v1/voice/cache/invalidate \
  -H "Authorization: Bearer <your_login_jwt>" \
  -H "Content-Type: application/json" \
  -d '{"backend": "edge-tts", "all": false}'

Error Codes

CodeDescription
voice_backend_unavailableThe requested backend is not configured or offline
voice_not_foundThe specified voice ID does not exist
audio_format_unsupportedThe uploaded audio format is not supported
transcription_failedSTT processing failed
model_not_installedThe requested TTS model is not installed
text_too_longInput text exceeds the maximum length (10,000 characters)