Real-time Voice (Text-to-Speech)

    VALSEA provides real-time Text-to-Speech over WebSocket for low-latency audio playback. Use this live endpoint when audio must begin streaming before the complete response is available. For single-request generation, use Batch Text-to-Speech.

    Batch vs. Real-time TTS

    Both modes generate speech from text and use the same stable VALSEA voice names. Batch TTS returns one complete audio response; Real-time TTS streams audio chunks as they are generated.

    ModeEndpointModelBest for
    Batch TTSPOST /v1/audio/speechvalsea-ttsComplete files and single-request generation
    Real-time TTSWS /v1/realtime/ttsvalsea-tts-realtimeConversational playback and low time-to-first-audio

    Connection

    Endpoint: wss://api.valsea.ai/v1/realtime/tts

    Authenticate during the WebSocket handshake with one of these options:

    • Authorization: Bearer YOUR_API_KEY
    • X-API-Key: YOUR_API_KEY
    • Query parameter: api_key=YOUR_API_KEY

    Message Flow

    1. Connect to the WebSocket endpoint.
    2. Receive session.created.
    3. Send session.start with model, voice, language, and output options.
    4. Receive session.ready.
    5. Send speech.create with the text input.
    6. Receive speech.started, then binary audio chunks, then speech.finished.
    7. Send session.stop to close cleanly.

    Client Messages

    session.start

    {
      "type": "session.start",
      "model": "valsea-tts-realtime",
      "language": "vietnamese",
      "voice": "valsea-neutral",
      "response_format": "mp3",
      "speed": 1,
      "normalization": "basic",
      "audio_quality": 64
    }
    
    FieldTypeDescription
    modelvalsea-tts-realtimeReal-time TTS model.
    languagestringA code from Supported Languages.
    voicea supported voiceVoice name for the selected language.
    response_formatmp3 | wav | opusBinary audio chunk format.
    speednumber | "default"Playback speed from 0.25 to 4, or the preset default.
    stabilitynumber | "default"Arabic voice stability from 0 to 1, or preset default.
    normalizationno | basic | advancedText normalization level.
    audio_qualityintegerAudio quality value. Default: 64.

    Supported Languages

    Real-time TTS accepts vietnamese, english, english-in, hindi, bengali-in, kannada, malayalam, marathi, odia (also accepted as oriya), punjabi, tamil, telugu, gujarati, and arabic.

    sinhala is currently available through Batch Text-to-Speech, not Real-time TTS.

    Voices

    Use valsea-neutral, valsea-male, or valsea-female for every supported language except Arabic. For language: "arabic", use one of these dedicated presets:

    VoiceDescription
    valsea-arabic-mid-female-emiratiMid-Female (Emirati)
    valsea-arabic-lively-female-emiratiLively-Female (Emirati)
    valsea-arabic-calm-male-emiratiCalm-Male (Emirati)
    valsea-arabic-calm-mid-male-emiratiCalm-Mid-Male (Emirati)

    Each Arabic preset has tuned speed and stability defaults. Omit either field or use "default" to retain the preset value.

    Arabic session

    {
      "type": "session.start",
      "model": "valsea-tts-realtime",
      "language": "arabic",
      "voice": "valsea-arabic-mid-female-emirati",
      "speed": "default",
      "stability": "default"
    }
    

    speech.create

    {
      "type": "speech.create",
      "input": "Xin chao, day la giong noi VALSEA."
    }
    

    session.stop

    { "type": "session.stop" }
    

    Server Messages

    session.created

    {
      "type": "session.created",
      "sessionId": "tts_...",
      "supportedModels": ["valsea-tts-realtime"],
      "supportedVoices": ["valsea-neutral", "valsea-male", "valsea-female"],
      "supportedLanguages": [
        "vietnamese",
        "english",
        "english-in",
        "hindi",
        "bengali-in",
        "kannada",
        "malayalam",
        "marathi",
        "odia",
        "oriya",
        "punjabi",
        "tamil",
        "telugu",
        "gujarati",
        "arabic"
      ]
    }
    

    The supportedVoices value currently lists the three general-purpose aliases. Arabic sessions use one of the dedicated presets listed in Voices.

    session.ready

    {
      "type": "session.ready",
      "sessionId": "tts_...",
      "model": "valsea-tts-realtime"
    }
    

    Audio events

    The server sends speech.started, then binary audio WebSocket frames, then speech.finished.

    { "type": "speech.started", "sessionId": "tts_..." }
    
    { "type": "speech.finished", "sessionId": "tts_..." }
    

    Example

    const WebSocket = require('ws');
    const fs = require('fs');
    
    const ws = new WebSocket('wss://api.valsea.ai/v1/realtime/tts', {
      headers: { Authorization: 'Bearer YOUR_API_KEY' },
    });
    
    const chunks = [];
    
    ws.on('message', (data, isBinary) => {
      if (isBinary) {
        chunks.push(Buffer.from(data));
        return;
      }
    
      const message = JSON.parse(data.toString());
    
      if (message.type === 'session.created') {
        ws.send(
          JSON.stringify({
            type: 'session.start',
            model: 'valsea-tts-realtime',
            language: 'vietnamese',
            voice: 'valsea-neutral',
            response_format: 'mp3',
          }),
        );
      }
    
      if (message.type === 'session.ready') {
        ws.send(
          JSON.stringify({
            type: 'speech.create',
            input: 'Xin chao, day la giong noi VALSEA.',
          }),
        );
      }
    
      if (message.type === 'speech.finished') {
        fs.writeFileSync('speech.mp3', Buffer.concat(chunks));
        ws.send(JSON.stringify({ type: 'session.stop' }));
      }
    });
    

    Billing

    Real-time TTS is billed by generated audio duration, rounded up to the next whole minute.

    Was this page helpful?