moses

Moses STT and TTS for Pipecat: a realtime voice agent with the pipecat-moses plugin

pipecat-moses adds Moses realtime speech to text and text to speech to Pipecat: finals 0.15 s after the turn ends, first audio 0.12 s after the first text. Code included.

Pipecat is the most widely used open-source framework for realtime voice agents: you build a pipeline of frame processors (transport in, speech to text, an LLM, text to speech, transport out) and Pipecat handles turn-taking, interruptions and the plumbing. Today we’re releasing pipecat-moses, which adds the Moses STT and Moses TTS APIs to it as native services. This article shows how to use them, what happens under the hood, and what to check before production.

Why a native plugin

Moses already speaks OpenAI’s audio API, so Pipecat’s stock OpenAITTSService and OpenAISTTService work with a changed base_url (see OpenAI compatibility). That is a quick start, but it leaves the best parts out:

  • Streaming in both directions. The plugin uses the realtime WebSockets. The LLM’s tokens go to TTS as they arrive, and STT sends partial transcripts while the user is still talking. With the HTTP services, every sentence is a new request and every utterance a file upload.
  • A final at the end of the turn. When Pipecat’s VAD decides the user has finished, the STT service sends flush, and the final transcript arrives about 0.15 s later. It doesn’t wait for the server’s own silence detection on top.
  • All languages and voices. Pipecat’s OpenAI TTS only accepts OpenAI voice names and sends no language, so it can only speak English. The plugin speaks all seven TTS languages, with every built-in voice and your cloned voices.
  • Interruptions. When the user barges in, TTS is cancelled on the server within one audio chunk, not only muted locally.

Install

uv add pipecat-moses        # or: pip install pipecat-moses

Create a key with the TTS and STT scopes in the API console and set it as MOSES_API_KEY. New accounts get trial credit. The plugin is tested with Pipecat 1.17 and released under the BSD 2-Clause licence, like Pipecat.

The pipeline

The two services take the place of any other STT and TTS service:

import os
from pipecat.audio.vad.silero import SileroVADAnalyzer
from pipecat.pipeline.pipeline import Pipeline
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.processors.aggregators.llm_response_universal import (
    LLMContextAggregatorPair, LLMUserAggregatorParams)
from pipecat.services.openai.llm import OpenAILLMService
from pipecat_moses import MosesSTTService, MosesTTSService

stt = MosesSTTService(
    api_key=os.environ["MOSES_API_KEY"],
    settings=MosesSTTService.Settings(language="de"),       # None detects the language
)
tts = MosesTTSService(
    api_key=os.environ["MOSES_API_KEY"],
    settings=MosesTTSService.Settings(voice="german/juergen", language="de"),
)
llm = OpenAILLMService(
    api_key=os.environ["OPENAI_API_KEY"],
    settings=OpenAILLMService.Settings(system_instruction=(
        "You are a helpful assistant in a voice conversation. Your answers are spoken, "
        "so keep them short and avoid lists or formatting.")),
)

context = LLMContext()
user_aggregator, assistant_aggregator = LLMContextAggregatorPair(
    context, user_params=LLMUserAggregatorParams(vad_analyzer=SileroVADAnalyzer()))

pipeline = Pipeline([
    transport.input(), stt, user_aggregator, llm, tts, transport.output(), assistant_aggregator,
])

Everything around it (the transport, the pipeline worker, the runner) is standard Pipecat. The repository has the complete bot, based on Pipecat’s own voice-agent example.

What happens under the hood

  1. Listening. The STT service streams the microphone audio to wss://moses-ai.com/stt/realtime and pushes partial transcripts into the pipeline as interim frames, so the context aggregator already has the words when the turn ends.
  2. End of turn. Pipecat’s VAD reports that the user stopped. The service sends flush, and the final transcript arrives about 0.15 s later (measured from Germany, network included).
  3. Speaking. The LLM streams its answer. The TTS service passes each token to wss://moses-ai.com/tts/realtime as it arrives. The server cuts the text at clauses and sentences itself, and the first audio comes back about 0.12 s after the first text. A voice worker is reserved for the connection when the bot starts (warmup), so the first answer is as fast as the rest.
  4. Interruptions. When the user starts talking over the bot, Pipecat interrupts the pipeline and the TTS service sends cancel. The audio stops within one chunk and queued text is dropped.

For a full latency budget of a voice agent, and where the rest of the time goes, see Voice agent latency: where the milliseconds go.

Languages and voices

  • Speech to text: 25 European languages (bg, cs, da, de, el, en, es, et, fi, fr, hr, hu, it, lt, lv, mt, nl, pl, pt, ro, ru, sk, sl, sv, uk). Leave language as None to detect it, or set it when you know it: that is a little more accurate.
  • Text to speech: English, German, French, Italian, Portuguese, Spanish and Dutch, with 27 built-in voices (GET /tts/v1/voices lists them).
  • Your own voice: clone one from a 10 to 20 second recording and pass voice="clone:anna".
  • Changing mid-call: push an STTUpdateSettingsFrame or TTSUpdateSettingsFrame to switch language, voice or the end-of-utterance pause without reconnecting. That is how a bot follows a caller who switches from German to English.

Run the example in five minutes

git clone https://github.com/mosesplatform/pipecat-moses && cd pipecat-moses
uv sync --extra example
cp env.example .env              # MOSES_API_KEY, OPENAI_API_KEY
uv run examples/voice_agent.py   # then open http://localhost:7860/client

Talk to it in the browser. Set MOSES_LANGUAGE=de and MOSES_VOICE=german/juergen in .env to talk German. Interrupt it mid-sentence to hear barge-in.

Before production

  • Capacity. Each bot uses one STT stream and one TTS connection. Accounts start with two of each at once. Ask Support before launch, and we raise the limit for your account.
  • A server key. A Pipecat server sends all calls from one IP address. Mark its key as a server key in the console, so the per-IP limit for keys in apps doesn’t apply. Account limits and your credit still do.
  • Errors that stay errors. A wrong key, a key without the STT or TTS scope, or no credit stops the service with an error frame instead of reconnecting in a loop.
  • Errors that heal. If a speech server goes away mid-call, the connection closes with a “try again” code and the service reconnects to another one by itself.
  • Privacy. Audio, text and transcripts are processed in Germany and not stored; only the amounts are recorded, for billing.
  • Cost. Prepaid credit, billed per character of speech and per second of audio transcribed, with no subscription; see pricing.

The plugin’s settings, limits and changelog are on the Pipecat docs page; the source is on GitHub. Building on LiveKit instead? The same APIs are in livekit-plugins-moses.

Frequently asked questions

Does Moses work with Pipecat?

Yes. The pipecat-moses package on PyPI provides MosesSTTService and MosesTTSService for Pipecat. They use the Moses realtime WebSockets and work in any Pipecat pipeline and with any transport: WebRTC, Daily, LiveKit or Twilio.

How fast are the Moses Pipecat services?

Measured from Germany with network included, the final transcript arrives about 0.15 s after Pipecat's VAD reports the end of the user's turn, and the first audio about 0.12 s after the first text from the LLM.

Which languages does pipecat-moses support?

Speech to text: 25 European languages, including English, German, French, Spanish, Italian, Dutch, Polish and Ukrainian, with automatic detection. Text to speech: English, German, French, Italian, Portuguese, Spanish and Dutch.

Can I use Pipecat's OpenAI services with Moses instead?

Yes. OpenAITTSService and OpenAISTTService work with base_url set to https://moses-ai.com/tts/v1 or /stt/v1. The plugin is faster, because it uses the realtime WebSockets, and its TTS supports every language and voice instead of English with OpenAI voice names.

How many calls can one account run at once?

Each bot uses one STT stream and one TTS connection. Accounts start with two of each at the same time; ask Support to raise the limit for production traffic.

Try the realtime voice APIs

Streaming speech to text and text to speech for voice agents, hosted in Germany, with no audio stored. Try both in your browser with an API key.

Open the live example