> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rumik.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# build a voice agent with pipecat

> a complete, from-scratch walkthrough: a real-time voice agent that talks back in hinglish.

by the end you'll have a voice agent you can talk to, that replies out loud in
natural hinglish using rumik. we'll build it with
[pipecat](https://github.com/pipecat-ai/pipecat), an open-source framework for
real-time voice.

## what you'll build

a real-time loop: you speak, the agent transcribes you, an LLM writes a reply, and
silk speaks it back.

```
🎙️ you speak  →  STT (deepgram)  →  LLM (openai)  →  rumik TTS  →  🔊 it speaks
```

you'll wire up three services. silk is the voice. you can swap the STT and LLM for
any provider pipecat supports.

## before you start

you need:

* **python 3.10+** and a terminal.
* three API keys:
  * **rumik** for the voice, from [your dashboard](https://playground.rumik.ai/api-keys).
  * **deepgram** for speech-to-text ([deepgram.com](https://deepgram.com)).
  * **openai** for the LLM ([platform.openai.com](https://platform.openai.com)).

<Note>
  you can swap deepgram or openai for any STT / LLM that pipecat supports. we use
  these two because they're quick to set up.
</Note>

## step 1 · set up the project

make a folder, a virtual environment, and install the packages.

```bash theme={null}
mkdir rumik-voice-agent && cd rumik-voice-agent
python -m venv venv
source venv/bin/activate        # windows: venv\Scripts\activate

pip install "pipecat-ai[deepgram,openai,silero]" pipecat-rumik
```

`pipecat-rumik` is the official rumik TTS service. the rest is pipecat plus the
STT and LLM plugins.

## step 2 · add your keys

create a file called `.env` in the folder:

```bash .env theme={null}
RUMIK_API_KEY=rk_live_•••••••••
RUMIK_GATEWAY_URL=https://silk-api.rumik.ai
DEEPGRAM_API_KEY=•••••••••
OPENAI_API_KEY=sk-•••••••••
```

never hard-code keys in your script. we'll load them from this file.

## step 3 · write the agent

create `agent.py`. this builds the four-step loop. the rumik part is the `tts`
line.

```python agent.py theme={null}
import os
from dotenv import load_dotenv

from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
from pipecat.pipeline.task import PipelineTask
from pipecat.services.deepgram.stt import DeepgramSTTService
from pipecat.services.openai.llm import OpenAILLMService
from pipecat_rumik import RumikTTSService

load_dotenv()

# speech to text
stt = DeepgramSTTService(api_key=os.environ["DEEPGRAM_API_KEY"])

# the brain. keep replies short and in romanised hinglish so muga sounds natural.
llm = OpenAILLMService(
    api_key=os.environ["OPENAI_API_KEY"],
    model="gpt-4o-mini",
)

# the voice: rumik muga
tts = RumikTTSService(
    api_key=os.environ["RUMIK_API_KEY"],
    gateway_url=os.environ["RUMIK_GATEWAY_URL"],
    settings=RumikTTSService.Settings(model="muga"),
)

# the loop: audio in → stt → llm → rumik tts → audio out
pipeline = Pipeline([stt, llm, tts])

# connect this pipeline to a transport (a phone call, a web room, or your mic)
# and run it. see the runnable examples linked below for a complete transport.
```

<Note>
  the surrounding pieces (the transport that carries audio, the system prompt, the
  context aggregator) come straight from the pipecat quickstart. the
  [`pipecat-rumik` examples](https://pypi.org/project/pipecat-rumik/) ship a
  complete, runnable agent you can copy.
</Note>

## step 4 · make the LLM speak muga's language

muga is steered by a `[tone]` tag at the start of each reply. tell your LLM to add
one. paste this into the LLM's system prompt:

```text theme={null}
You write text spoken by the Silk Muga 1 text-to-speech model.

- Output only the final tagged text, no markdown or notes.
- Romanised Hinglish only (Latin script). Never Devanagari.
- Start every paragraph with one tone tag, as the first token:
  [happy], [excited], [sad], [angry], [neutral], [whisper].
- Keep replies short: 1 to 2 sentences.
```

now the LLM produces `[happy] Haan ji, ho gaya!` and silk speaks it with the right
emotion. the full prompt rules are in [prompting muga](/prompting-muga).

## step 5 · run it

```bash theme={null}
python agent.py
```

speak into your mic. you'll hear muga reply in hinglish. it streams, so the first
audio comes back fast, and pipecat handles interruptions for you.

## customize it

<CardGroup cols={2}>
  <Card title="change the voice" icon="microphone-lines">
    switch to `model="mulberry"` and add a `description` to design any voice. see
    [prompting mulberry](/prompting-mulberry).
  </Card>

  <Card title="tune the personality" icon="sliders">
    edit the LLM system prompt. that's the agent's character.
  </Card>

  <Card title="swap STT or LLM" icon="shuffle">
    pipecat supports many providers. change the `stt` or `llm` line.
  </Card>

  <Card title="let an agent do it" icon="robot">
    hand the [rumik TTS skill](/agent-skill) to your coding agent.
  </Card>
</CardGroup>

## next steps

* [pipecat integration reference](/pipecat) for every setting and both transports.
* [prompting muga](/prompting-muga) and [prompting mulberry](/prompting-mulberry).
* prefer livekit? build the [same agent with livekit](/cookbook/voice-agent-livekit).
