Metadata-Version: 2.5
Name: pipecat-moses
Version: 0.1.0
Summary: Moses realtime speech-to-text (25 European languages) and text-to-speech for Pipecat: hosted in Germany, nothing stored.
Project-URL: Homepage, https://moses-ai.com/tts_stt/pipecat.html
Project-URL: Documentation, https://moses-ai.com/tts_stt/pipecat.html
Project-URL: Pricing, https://moses-ai.com/pricing
Project-URL: Repository, https://github.com/mosesplatform/pipecat-moses
Project-URL: Changelog, https://github.com/mosesplatform/pipecat-moses/blob/main/CHANGELOG.md
Author: Moses AI
License-Expression: BSD-2-Clause
License-File: LICENSE
Keywords: european,gdpr,german,moses,pipecat,realtime,speech-to-text,stt,text-to-speech,tts,voice agent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
Requires-Python: >=3.11
Requires-Dist: pipecat-ai<2,>=1.17.0
Provides-Extra: example
Requires-Dist: pipecat-ai[openai,runner,silero,webrtc]<2,>=1.17.0; extra == 'example'
Requires-Dist: python-dotenv; extra == 'example'
Description-Content-Type: text/markdown

# pipecat-moses

[Moses](https://moses-ai.com) realtime speech-to-text and text-to-speech for [Pipecat](https://github.com/pipecat-ai/pipecat).

- **Speech-to-text** in 25 European languages: partial transcripts while the user speaks, and the final as soon as
  Pipecat's VAD hears the end of the turn (the service sends `flush`, so there is no second pause to wait for).
- **Text-to-speech** in 7 languages (English, German, French, Italian, Portuguese, Spanish, Dutch), with 27
  built-in voices or your own recorded voice. The LLM's tokens are streamed as they arrive; the first audio of an
  answer starts after the first clause.
- **Hosted in Germany, nothing stored:** audio, text and transcripts are processed in memory and dropped. Only the
  amount (seconds of audio, characters) is recorded for billing. Prepaid credit, no subscription.

Maintained by Moses AI, the company behind the service.

## Installation

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

Get an API key with the **TTS** and **STT** scopes at [moses-ai.com/console](https://moses-ai.com/console) (new
accounts come with trial credit) and set it as `MOSES_API_KEY`.

## Usage

```python
import os

from pipecat.pipeline.pipeline import Pipeline
from pipecat_moses import MosesSTTService, MosesTTSService

stt = MosesSTTService(
    api_key=os.environ["MOSES_API_KEY"],
    settings=MosesSTTService.Settings(language="de"),       # or None to detect the language
)
tts = MosesTTSService(
    api_key=os.environ["MOSES_API_KEY"],
    settings=MosesTTSService.Settings(voice="german/juergen", language="de"),
)

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

### `MosesSTTService`

| Argument | Default | |
|---|---|---|
| `api_key` | required | Key with the STT scope |
| `url` | `wss://moses-ai.com/stt/realtime` | |
| `sample_rate` | pipeline input rate | 8000, 16000, 24000, 32000 or 48000 |
| `flush_on_vad_stop` | `True` | Send `flush` when Pipecat's VAD reports the end of speech |
| `ttfs_p99_latency` | measured value | P99 end of speech → final transcript, used by Pipecat's turn strategies |

`Settings` (change them at runtime with `STTUpdateSettingsFrame`; no reconnect):

| Field | Default | |
|---|---|---|
| `language` | `None` (detect) | `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`. Set it when you know it: short utterances are then decoded again in that language if they come out as English. |
| `endpoint_ms` | server default (300) | The server's own end-of-utterance pause, 100–3000 ms |
| `interim_results` | `True` | Partial transcripts |

### `MosesTTSService`

| Argument | Default | |
|---|---|---|
| `api_key` | required | Key with the TTS scope |
| `url` | `wss://moses-ai.com/tts/realtime` | |
| `warmup` | `True` | Reserve a voice worker for the connection at once, for the fastest first audio |
| `text_aggregation_mode` | `TOKEN` | Stream tokens and let Moses cut clauses; `SENTENCE` sends whole sentences |

`Settings` (change them at runtime with `TTSUpdateSettingsFrame`; applied from the next segment):

| Field | Default | |
|---|---|---|
| `voice` | `alba` | English: `alba`, `anna`, `vera`, `marius`, `jean`, … (21 voices); `german/juergen`, `french/estelle`, `italian/giovanni`, `portuguese/rafael`, `spanish/lola`, `dutch/daan`; your own voice: `clone:<name>`. List: `GET https://moses-ai.com/tts/v1/voices` |
| `language` | the voice's | `en de fr it pt es nl`. With `clone:<name>`, your voice speaks that language |
| `first_chunk_chars` | 30 | Minimum length before the first segment may be cut at a comma |

Audio comes as 24 kHz PCM; Pipecat resamples it to the pipeline's output rate.

## Running the example

`examples/voice_agent.py` is a complete voice agent (Moses STT and TTS, an OpenAI LLM, Silero VAD) on Pipecat's
development runner:

```bash
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   # open http://localhost:7860/client and talk
```

`MOSES_LANGUAGE=de MOSES_VOICE=german/juergen uv run examples/voice_agent.py` talks German.

## Latency

Measured from Germany, network included:
- STT: the final transcript arrives about 0.15 s after Pipecat's VAD reports the end of speech.
- TTS: the first audio arrives about 0.12 s after the first text.

## Limits and errors

- Per account at once: 2 STT streams and 2 TTS connections by default (ask for more). Each bot uses one of each.
- A wrong key, a key without the needed scope, or no credit stops the service with an error instead of
  reconnecting. A lost worker or a full server is retried.
- `revision` events (a final decoded again in the set language) are logged, not pushed: the first final has
  already gone to the LLM.

## Compatibility

Tested with Pipecat 1.17.0. Python 3.11+.

## Links

- [Pricing](https://moses-ai.com/pricing) · [STT API](https://moses-ai.com/stt/) · [TTS API](https://moses-ai.com/tts/)
- Changelog: [CHANGELOG.md](CHANGELOG.md)

## License

BSD 2-Clause, see [LICENSE](LICENSE).
