Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

speech-to-speech

> 编程语言
Open source

Build local voice agents with open-source models

10.1K stars0 likes0 views
WebsiteGitHub

About

Build local voice agents with open-source models

Speech To Speech: Build voice agents with open-source models

A low-latency, fully modular voice-agent pipeline: VAD -> STT -> LLM -> TTS, exposed through the core OpenAI Realtime GA event set over WebSocket and WebRTC. Every component is swappable. The LLM slot speaks OpenAI-compatible protocols, so you can point it at a hosted provider, at HF Inference Providers, or at a vLLM or llama.cpp server on your own hardware for a fully local, fully open stack.

This pipeline runs in production as the conversation backend for thousands of Reachy Mini robots.

Quickstart

Choose where the language model should run. All three configurations use local Parakeet TDT speech recognition and Qwen3-TTS speech output by default. You can change the STT, LLM, and TTS models and backends; see Supported components. Each configuration runs from one terminal with the packaged microphone/speaker client.

Starting configuration Hardware to plan for Conversation data sent to a provider
Apple Silicon, fully local Apple Silicon Mac; budget 16 GB or more of unified memory None
NVIDIA GPU, fully local Linux with an NVIDIA GPU; budget 24 GB of VRAM for the unquantized LLM, speech models, and caches below, plus system RAM None
Local speech with a hosted LLM Apple Silicon: budget ~8 GB of available unified memory (16 GB total recommended); Linux/NVIDIA: ~8 GB of available VRAM, plus system RAM Transcribed text, instructions, and conversation history; microphone audio stays local

The memory figures are planning estimates for one conversation, not measured minimum requirements. Actual use depends on context length, audio length, and backend versions. All configurations need internet access for the first model downloads; the hosted LLM also needs an API key and internet access during conversations.

Install for these examples

Use Python 3.10+ (Python 3.11 recommended) and install the package in a virtual environment.

On Ubuntu, install the local audio libraries first: sudo apt-get install libportaudio2 libsndfile1. The default Linux Qwen3-TTS wheel targets CUDA 12.8 and glibc 2.39 (Ubuntu 24.04); check the CUDA installation note if your system differs.

bash
python3 -m venv .venv
source .venv/bin/activate
pip install speech-to-speech

Run the configuration you chose with this environment activated. Activate the same environment in any additional terminal where you run speech-to-speech. The first run downloads and warms up the models before connecting the microphone. Allow microphone access if prompted, use headphones to avoid speaker feedback, then speak and pause for a reply. Stop with Ctrl+C.

If speaker feedback interrupts replies, add --local_audio_block_mic_during_playback to your speech-to-speech local command. This pauses microphone capture during playback, so you cannot interrupt the assistant while it speaks.

Apple Silicon, fully local

Run all three models locally on an Apple Silicon Mac, using a quantized LLM through MLX. No API key is needed.

bash
speech-to-speech local \
    --mac-optimal-settings \
    --model_name mlx-community/Qwen3-4B-Instruct-2507-4bit

The Mac preset selects Parakeet TDT through MLX, the 4-bit Qwen3-4B language model through MLX LM, and the 6-bit Qwen3-TTS CustomVoice model through MLX Audio. The core model weights total approximately 7.5 GB: STT, LLM, and TTS. Allow additional disk space for dependencies and auxiliary model assets.

For a separate local LLM server, see Combining with llama.cpp. For a model that accepts audio directly, see the Gemma 4 12B example.

NVIDIA GPU, fully local

Run all three models locally on a Linux workstation with a CUDA-capable NVIDIA GPU. Transformers loads the LLM in the speech process, so no separate LLM server or API key is needed.

bash
speech-to-speech local \
    --device cuda \
    --stt parakeet-tdt \
    --llm_backend transformers \
    --model_name Qwen/Qwen3-4B-Instruct-2507 \
    --llm_torch_dtype float16 \
    --tts qwen3 \
    --qwen3_tts_backend ggml

The LLM weights alone are approximately 8 GB; speech models, caches, and dependencies need additional disk space. For a quantized LLM in a separate server, see Combining with llama.cpp, available on both Apple Silicon and NVIDIA.

Local speech with a hosted LLM

Run speech recognition and synthesis locally on Apple Silicon or Linux/NVIDIA while a hosted LLM generates replies. The speech backends select MLX automatically on Apple Silicon.

Budget approximately 8 GB of available memory for the local speech pipeline: unified memory on Apple Silicon (16 GB total recommended) or GPU VRAM on NVIDIA, with separate system RAM. Leave room for the operating system and other apps.

bash
export OPENAI_API_KEY=...
speech-to-speech local \
    --stt parakeet-tdt \
    --llm_backend responses-api \
    --tts qwen3

This uses the default OpenAI model described under Realtime Server, with provider API charges. Only the speech models download locally: approximately 5.2 GB of core weights on Apple Silicon, plus dependencies and auxiliary assets; Linux uses different speech-model formats and caches. Transcribed text, instructions, and conversation history are sent to OpenAI. Microphone audio and speech synthesis remain on your computer in this configuration. For another provider, see LLM backends.

Other clients and offline use

For offline use, first cache the selected models and dependencies as described in Offline operation.

To connect an app instead of the packaged microphone client, replace local with serve in your chosen speech-to-speech command, keeping any separate LLM server running. The speech server listens at ws://127.0.0.1:8765/v1/realtime. You can then connect from another terminal with the same Python environment activated:

bash
speech-to-speech talk --url ws://127.0.0.1:8765/v1/realtime

For a browser interface, start your chosen configuration with serve, then follow the browser demo setup using that running backend.

Clients using the implemented core Realtime event set can connect. The official OpenAI Agents SDK is tested over both stock transports; see Realtime API for the tested surface and LLM backends for provider and local-server options.

Index

  • How it works
  • Starting configurations
  • Installation
  • Offline operation
  • Supported components
  • Commands
  • Realtime API
  • LLM backends
  • Multi-language support
  • OmniVoice
  • Pocket TTS
  • CLI reference
  • Contributing
  • Star history
  • Citations

How it works

The pipeline is a cascade of four components, each running in its own thread and connected by queues:

  1. Voice Activity Detection (VAD): Silero VAD v5 detects speech boundaries and turn-taking.
  2. Speech to Text (STT): transcribes the user's turn, with optional live partial transcripts.
  3. Language Model (LLM): generates the response, streaming text and tool calls.
  4. Text to Speech (TTS): synthesizes audio and streams it back to the client.

Every stage has multiple interchangeable backends, selected via CLI flags. The code is designed for easy modification, with a focus on models available through Transformers and the Hugging Face Hub.

Installation

Requires Python 3.10+. Install from PyPI in an activated virtual environment (see the quickstart setup):

bash
pip install speech-to-speech

The default install covers the standard realtime path:

  • Parakeet TDT for STT
  • OpenAI-compatible API for the language model
  • Qwen3-TTS for speech output, using the GGML backend by default on non-macOS platforms and mlx-audio on Apple Silicon
  • local audio and realtime server modes

macOS and non-macOS dependencies are resolved automatically via platform markers in pyproject.toml.

CUDA Note for Qwen3-TTS

On Linux, the Qwen3-TTS GGML backend comes from faster-qwen3-tts[ggml]. Its default qwentts-cpp-python wheel on PyPI targets CUDA 12.8 and manylinux_2_39 (for example, Ubuntu 24.04). If your CUDA runtime or glibc is older, install the matching wheel from the Hugging Face wheelhouse before installing speech-to-speech:

bash
# CUDA 13.x
pip install "qwentts-cpp-python==0.3.1+cu130" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/tree/main/whl/cu130

# CUDA 12.4
pip install "qwentts-cpp-python==0.3.1+cu124" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/tree/main/whl/cu124

# CPU-only fallback
pip install "qwentts-cpp-python==0.3.1+cpu" \
  -f https://huggingface.co/datasets/andito/qwentts-cpp-python-wheels/tree/main/whl/cpu

pip install speech-to-speech

To use the previous CUDA-graphs implementation instead of GGML, pass --qwen3_tts_backend torch.

Optional Components

Optional components are installed with pip extras:

…

Deprecated implementations, including MeloTTS, live in archive/ and are no longer wired into the CLI.

Note on DeepFilterNet: DeepFilterNet, used for optional audio enhancement in VAD, requires numpy<2 and conflicts with Pocket TTS, which requires numpy>=2. Install it manually only in environments where you are not using Pocket TTS.

From Source

To work on the code, install Git and uv, then run:

bash
git clone https://github.com/huggingface/speech-to-speech.git
cd speech-to-speech
uv sync --python 3.11
source .venv/bin/activate

This installs the package in editable mode. With the environment activated, use the same speech-to-speech commands shown above.

Supported Components

Component Backend Platforms Install
VAD Silero VAD v5 all built-in
STT Parakeet TDT (default) CUDA / CPU through nano-parakeet, Apple Silicon through MLX built-in
STT Whisper through Transformers CUDA / CPU built-in
STT Faster Whisper CUDA / CPU faster-whisper
STT Lightning Whisper MLX Apple Silicon whisper-mlx
STT MLX Audio Whisper Apple Silicon built-in on macOS
STT Paraformer CUDA / CPU paraformer
STT [Qwen3-ASR](https://huggingface.co/

Issues· 113 open

View all issuesOpen on GitHub
  • #455

    WebRTC audio clear can replay a stashed output chunk

    Updated Sep 28, 2026
  • #563

    STT can hallucinate confident, mislabeled transcriptions with no confidence signal, leading to nonsensical input reaching the LLM

    Updated Sep 28, 2026
  • #565

    Listener backchannels abort active response mid-playback

    Updated Sep 27, 2026
  • #577

    Local tool calls lose positional arguments and are skipped when required parameters disappear

    Updated Sep 27, 2026
  • #590

    Extend response latency logging to additional STT, LLM, and TTS backends

    Updated Sep 25, 2026
  • #582

    Default macOS local setup intermittently goes off-rail

    Updated Sep 23, 2026
  • #547

    Support optional mid-session STT, LLM, and TTS model switching through session.update

    for-hf-staff-onlyUpdated Sep 23, 2026
  • #558

    Sending silence on RTC causes noticable per-client background CPU usage

    Updated Sep 19, 2026
  • #489

    Add opt-in speculative input transcription snapshot events

    Updated Sep 19, 2026
  • #519

    Preserve Responses API reasoning items during tool continuations

    enhancementUpdated Sep 16, 2026

> Tags

Pythonaiassistantlanguage-modelmachine-learning

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 29, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言