Translation pending

इस पृष्ठ का अनुवाद अभी उपलब्ध नहीं है। नीचे दी गई सामग्री अंग्रेज़ी में है — संदर्भ: अंग्रेज़ी संस्करण।

Speech Server

Apple के लिए मूल रनटाइम · PocketTTS

PocketTTS, speech-swift में मूल CoreML वाक् संश्लेषण जोड़ता है। सभी चरण डिफ़ॉल्ट रूप से केवल CPU पर चलते हैं। अंग्रेज़ी Alba आवाज़ 24 kHz पर 1,920 नमूनों के फ़्रेम भेजती है, यानी हर फ़्रेम 80 मिलीसेकंड का है।

Swift और CLI का उपयोग

pocket-tts और alba आवाज़ का उपयोग करें। HTTP स्ट्रीमिंग के लिए PCM आवश्यक है; WebSocket ऑडियो अंश भेजता है। मौजूदा डिफ़ॉल्ट मॉडल यथावत हैं।

curl http://localhost:8080/v1/audio/speech \
  -H 'Content-Type: application/json' \
  -d '{"model":"pocket-tts","voice":"alba","input":"Hello world.","response_format":"pcm","stream":true}' \
  -o hello.pcm

speech-server is a local HTTP + WebSocket server that exposes every Soniqo model through a simple REST API, plus an OpenAI Realtime API-compatible WebSocket at /v1/realtime. It ships in the same Homebrew bottle as the speech CLI — brew install speech drops both on your PATH.

Install and run

brew install speech

speech-server --port 8080
# Starting server on http://127.0.0.1:8080
# Endpoints:
#   POST /transcribe  - Speech-to-text (WAV body or JSON with audio_base64)
#   POST /speak       - Text-to-speech (JSON: {text, engine?, language?})
#   POST /respond     - Speech-to-speech (WAV body, voice/max_steps via query)
#   POST /enhance     - Speech enhancement (WAV body)
#   GET  /health      - Health check
#   WS   /v1/realtime - OpenAI Realtime API (JSON events, base64 PCM16 audio)

Command-line flags

FlagDefaultDescription
--host127.0.0.1Bind address. Change to 0.0.0.0 to expose on LAN.
--port8080TCP port.
--preloadoffLoad all models eagerly at startup. Slower boot (~30–60 s) but zero first-request latency.

Models are downloaded on first use and cached in ~/Library/Caches/qwen3-speech/. The first request for a given model pays the download + load cost (30 s – 2 min depending on model size); subsequent requests are warm.

REST endpoints

POST /transcribe — Speech-to-text

Accepts either a raw WAV body or a JSON envelope with base64-encoded audio.

# WAV body (preferred — lower overhead)
curl -X POST http://127.0.0.1:8080/transcribe \
  -H "Content-Type: audio/wav" \
  --data-binary @recording.wav

# JSON with base64
curl -X POST http://127.0.0.1:8080/transcribe \
  -H "Content-Type: application/json" \
  -d '{"audio_base64":"'"$(base64 -i recording.wav)"'","language":"en"}'

Response: {"text": "…", "language": "en", "confidence": 0.93}.

POST /speak — Text-to-speech

curl -X POST http://127.0.0.1:8080/speak \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello, world!","engine":"kokoro","language":"en"}' \
  --output hello.wav

Response body is a WAV blob. Supported engine values: qwen3 (default), cosyvoice, kokoro.

POST /respond — Speech-to-speech

curl -X POST "http://127.0.0.1:8080/respond?voice=en_female_calm&max_steps=256" \
  -H "Content-Type: audio/wav" \
  --data-binary @question.wav \
  --output answer.wav

Runs PersonaPlex 7B — speech in, speech out. Transcript is returned as an X-Response-Text header. See PersonaPlex guide for voice preset names.

POST /enhance — Speech enhancement

curl -X POST http://127.0.0.1:8080/enhance \
  -H "Content-Type: audio/wav" \
  --data-binary @noisy.wav \
  --output clean.wav

DeepFilterNet3 at 48 kHz. Input is resampled if needed.

GET /health — Liveness probe

curl http://127.0.0.1:8080/health
# {"status":"ok"}

HTTP और रीयलटाइम WebSocket परीक्षण अधिकतम 10 सेकंड तक प्रतीक्षा करते हैं कि /health, HTTP 200 के साथ {"status":"ok"} लौटाए। शुरू होने में त्रुटि आने पर परीक्षण की तैयारी विफल होती है, और सफाई के दौरान पोर्ट का दोबारा उपयोग करने से पहले सर्वर के बंद होने की प्रतीक्षा की जाती है।

WebSocket: /v1/realtime

Drop-in compatible with the OpenAI Realtime API — the same JSON event schema (session.update, input_audio_buffer.append, response.create, response.audio.delta, …) with base64-encoded PCM16 audio at 24 kHz. Clients written against OpenAI's Realtime SDK work against speech-server without code changes (just switch the WebSocket URL).

Server VAD से automatic turns

Manual input_audio_buffer.commit डिफ़ॉल्ट रहता है। Server पर Silero VAD चलाने और हर पूर्ण speech turn को अपने आप transcribe करने के लिए session.turn_detection को server_vad पर सेट करें। Prefix audio सुरक्षित रहता है, idle buffering सीमित रहती है, speech_started, speech_stopped और committed events क्रम में आते हैं, और लगातार सक्रिय turn तय अधिकतम समय पर बंद होता है।

ws.send(JSON.stringify({
  type: "session.update",
  session: {
    turn_detection: {
      type: "server_vad",
      threshold: 0.5,
      prefix_padding_ms: 300,
      silence_duration_ms: 500,
      max_turn_duration_ms: 120000
    }
  }
}));

JavaScript example

const ws = new WebSocket("ws://127.0.0.1:8080/v1/realtime");

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: "session.update",
    session: { modalities: ["audio", "text"] }
  }));

  // Stream PCM16 mono 24kHz audio from the mic:
  const audioBase64 = await capturePCM16Chunk();
  ws.send(JSON.stringify({
    type: "input_audio_buffer.append",
    audio: audioBase64
  }));

  ws.send(JSON.stringify({ type: "response.create" }));
};

ws.onmessage = ev => {
  const msg = JSON.parse(ev.data);
  if (msg.type === "response.audio.delta") {
    playPCM16Base64(msg.delta);
  }
};

Python example

import asyncio, base64, json, wave, websockets

async def main():
    async with websockets.connect("ws://127.0.0.1:8080/v1/realtime") as ws:
        await ws.send(json.dumps({"type": "session.update",
                                  "session": {"modalities": ["audio", "text"]}}))

        with wave.open("question.wav", "rb") as wav:
            pcm16 = wav.readframes(wav.getnframes())
        await ws.send(json.dumps({"type": "input_audio_buffer.append",
                                  "audio": base64.b64encode(pcm16).decode()}))
        await ws.send(json.dumps({"type": "response.create"}))

        async for raw in ws:
            msg = json.loads(raw)
            if msg["type"] == "response.audio.delta":
                open("answer.pcm", "ab").write(base64.b64decode(msg["delta"]))
            elif msg["type"] == "response.done":
                break

asyncio.run(main())

Deployment notes

Source

वैकल्पिक मॉडल प्रबंधन

SpeechRuntime साझा लोडिंग, रद्द करने योग्य FIFO प्रवेश और क्रमिक निष्पादन प्रदान करता है। Qwen3ASRRuntime स्पष्ट विवरणकों से MLX या पूर्ण CoreML चुनता है; मूल API और CLI विकल्प उपलब्ध रहते हैं।

सर्वर स्ट्रीम आउटपुट सहित पूरे अनुरोध के दौरान एक निष्पादन अनुमति रखता है और अधिकतम 32 अनुरोध प्रतीक्षा कर सकते हैं। ASR विफलताएँ HTTP त्रुटियों या WebSocket त्रुटि घटनाओं के रूप में मिलती हैं; मान्य खाली ट्रांसक्रिप्ट सफल रहते हैं। प्लेबैक अतिरिक्त नमूने सुरक्षित रखता है। कैश मॉडल और प्रतीक्षारत ऑडियो मेमोरी लेते रहते हैं।

Voxtral TTS

Voxtral 4B TTS 2603, VoxtralTTS मॉड्यूल के ज़रिए Apple Silicon पर स्थानीय रूप से चलता है: 20 प्रीसेट आवाज़ें, नौ भाषाएँ और 24 kHz मोनो वाणी।

curl http://localhost:8080/v1/audio/speech \
  -H 'Content-Type: application/json' \
  -d '{"model":"voxtral-tts","input":"Hello, welcome to Voxtral.","voice":"casual_male","response_format":"wav"}' \
  -o hello.wav

केवल पहले से तय आवाज़ें उपलब्ध हैं; संदर्भ ऑडियो से आवाज़ की क्लोनिंग उपलब्ध नहीं है। SDK, CLI, WebSocket और HTTP PCM में ऑडियो बनते समय ही भेजा जाता है। पूरा इनपुट पाठ शुरुआत में देना होगा। मॉडल वेट CC BY-NC 4.0 लाइसेंस के अंतर्गत हैं।

Voxtral TTS गाइड पढ़ें