Skip to navigation

LiveKit & Murf

Build voice and multimodal conversational AI applications with Murf TTS and STT

Murf is available as a plugin for LiveKit Agents, a framework for building voice and multimodal conversational AI applications. Install the livekit-murf plugin to use Murf for both ends of the agent loop: Finch for speech-to-text and Falcon 2.1 for text-to-speech, with real-time streaming on each. Build voice agents covers the full agent loop and where latency comes from.

Murf AI plugin

The Murf plugin integrates Murf’s speech-to-text and text-to-speech capabilities with LiveKit Agents. Use murf.STT and murf.TTS inside an AgentSession to transcribe the caller and reply in a natural-sounding voice, both on one Murf API key.

Installation

Install the Murf plugin from PyPI:

Using pip

pip install livekit-murf

Using uv

uv add livekit-murf

This pulls in a compatible livekit-agents release (1.5.2 or later).

Don’t install livekit-murf and livekit-plugins-murf in the same environment. Both provide livekit.plugins.murf, and the one installed later replaces the other. livekit-plugins-murf is TTS-only, so use livekit-murf when you want Murf speech-to-text.

For Existing LiveKit Projects

If you already have a LiveKit project, you can quickly integrate Murf by initializing the murf.STT() and murf.TTS() classes in your existing AgentSession. Both read the same Murf API key from your environment variables. You can get your Murf API key from the Murf API Dashboard:

from livekit.plugins import murf
# Add Murf STT and TTS to your existing session
session = AgentSession(
stt=murf.STT(model="finch_indic_1.0", language="hi,en_IN"),
llm="your-llm-provider", # e.g., "openai/gpt-4o"
tts=murf.TTS(voice="Pooja", style="Conversational", model="falcon-2.1", locale="hi-IN")
# ... your existing configuration
)

View all configuration parameters →

Guide to Building Voice Agents with Murf and LiveKit

This guide provides setup instructions and examples for building your first LiveKit Agent with Murf STT and TTS.

Setup & Requirements

Before running the examples above, ensure you have everything configured properly:

Requirements

  • Python >= 3.10
  • livekit-murf >= 0.2.1 (livekit-agents >= 1.5.2)

Required Packages

The examples in this guide use Murf for speech-to-text and text-to-speech, along with LiveKit plugins for language models (OpenAI) and voice activity detection (Silero). Install all packages used in the examples:

pip install livekit-murf "livekit-agents[openai,silero]~=1.5" python-dotenv

API Keys

You’ll need API keys for the services used in your LiveKit Agent:

  • Murf API Key: Sign up at the Murf API Dashboard and generate your API key. The same key covers both STT and TTS.
  • LiveKit API Credentials: Get your LiveKit server URL, API key, and secret from LiveKit Cloud.
  • Additional Services: Depending on your setup, you may need an API key for your LLM (e.g., OpenAI) service

Environment Variables

To keep your API keys secure, it’s recommended to use environment variables. Create a .env file in your project root:

LIVEKIT_URL=wss://your-livekit-server.livekit.cloud # Your LiveKit server URL
LIVEKIT_API_KEY=your_livekit_api_key_here # Your LiveKit API key
LIVEKIT_API_SECRET=your_livekit_api_secret_here # Your LiveKit API secret
MURF_API_KEY=your_murf_api_key_here # Used by both Murf STT and TTS
OPENAI_API_KEY=your_openai_api_key_here # Required for LLM

Then load these variables in your Python code using python-dotenv:

from dotenv import load_dotenv
load_dotenv()

Quick Start Example

Here’s a simple example of how to create a LiveKit Agent Worker with Murf STT and TTS. It uses Finch-Indic to transcribe a caller speaking Hindi or English (India), and the Pooja voice to reply:

import logging
import os
from dotenv import load_dotenv
load_dotenv()
from livekit.agents import (
Agent,
AgentServer,
AgentSession,
JobContext,
JobProcess,
MetricsCollectedEvent,
cli,
metrics,
room_io,
)
from livekit.plugins import silero, murf
from livekit.plugins import openai as openai_plugin
logger = logging.getLogger("murf-agent")
class MyAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions=(
"You are a voice agent built using Murf. The caller speaks Hindi or Indian English, "
"often mixing the two. Reply in the language they used. Keep responses short and natural."
)
)
async def on_enter(self):
await self.session.say(
"Namaste! Main Murf se bani voice agent hoon. Aaj main aapki kya madad kar sakti hoon?"
)
server = AgentServer()
def prewarm(proc: JobProcess):
proc.userdata["vad"] = silero.VAD.load()
server.setup_fnc = prewarm
@server.rtc_session()
async def entrypoint(ctx: JobContext):
ctx.log_context_fields = {"room": ctx.room.name}
session = AgentSession(
stt=murf.STT(model="finch_indic_1.0", language="hi,en_IN"),
llm="openai/gpt-4o",
tts=murf.TTS(voice="Pooja", style="Conversational", locale="hi-IN"),
vad=ctx.proc.userdata["vad"],
preemptive_generation=True,
resume_false_interruption=True,
false_interruption_timeout=1.0,
)
usage_collector = metrics.UsageCollector()
@session.on("metrics_collected")
def on_metrics(ev: MetricsCollectedEvent):
metrics.log_metrics(ev.metrics)
usage_collector.collect(ev.metrics)
async def log_usage():
logger.info(f"Usage: {usage_collector.get_summary()}")
ctx.add_shutdown_callback(log_usage)
await session.start(
agent=MyAgent(),
room=ctx.room,
room_options=room_io.RoomOptions(
audio_input=room_io.AudioInputOptions()
),
)
if __name__ == "__main__":
cli.run_app(server)

Save this code as agent.py and run it with:

python agent.py console

This will start the agent in console where you can directly speak with the agent in the terminal and hear responses in Murf’s natural voice.

Livekit terminal Session

Configuration

The murf.STT and murf.TTS classes provide extensive configuration options to customize transcription and voice output according to your needs.

TTS Parameters Reference

ParameterTypeDefaultRange/OptionsDescription
voicestr"Gordon"Any valid Murf voice IDVoice identifier for speech generation
stylestr"Conversational"Voice-specific stylesVoice style (e.g., “Conversational”, “Narration”)
speedint0-50 to 50Speech rate adjustment
pitchint0-50 to 50Pitch adjustment
modelstr"falcon-2.1""falcon-2.1"The model to use for audio output
localestrNoneLanguage codes (e.g., "en-US")Locale for language-specific speech generation

STT Parameters Reference

murf.STT streams the caller’s audio to Murf’s Speech to Text WebSocket. Partials arrive while the caller is still speaking, and a final transcript arrives when they pause.

ParameterTypeDefaultRange/OptionsDescription
modelstr"finch_global_1.0""finch_indic_1.0", "finch_global_1.0"Finch version to transcribe with
languagestr | list"auto"Murf language codes, or "auto"A single code, or several as "hi,en_IN" or ["hi", "en_IN"] to detect from that set
sample_rateint160008000, 12000, 16000, 24000, 32000, 44100, 48000Rate audio is resampled to before it is sent to Murf
keywordslist[str]NoneWords or phrasesTerms to boost, such as product names and jargon
alphafloat0.50.0 to 1.0How strongly to favour keywords
text_formattingboolFalseTrue, FalseFormat numbers and similar terms. Hindi and English (India) only
bvcboolFalseTrue, FalseRemove background voices before transcription
api_keystrMURF_API_KEYYour Murf API keyFalls back to the MURF_API_KEY environment variable

Each Finch version is served on its own host and transcribes only its own languages. finch_indic_1.0 runs on in.api.murf.ai and covers 11 Indian languages plus English (India); finch_global_1.0 runs on us-east.api.murf.ai and covers English and six European languages. The Speech to Text overview lists both language sets.

Complete Example with Custom Configuration

Here’s a more advanced example showing how to customize the Murf STT and TTS configuration with metrics and error handling. It boosts the terms a support caller is likely to use, and formats numbers in the transcript:

import logging
import os
from dotenv import load_dotenv
load_dotenv()
from livekit.agents import (
Agent,
AgentServer,
AgentSession,
JobContext,
JobProcess,
MetricsCollectedEvent,
cli,
metrics,
room_io,
)
from livekit.plugins import silero, murf
from livekit.plugins import openai as openai_plugin
logger = logging.getLogger("murf-agent")
class CustomAgent(Agent):
def __init__(self) -> None:
super().__init__(
instructions=(
"You are a billing support assistant for callers in India. They speak Hindi or Indian "
"English and often mix the two. Reply in the language they used, with a natural speaking "
"style and concise answers."
)
)
async def on_enter(self):
await self.session.say(
"Namaste! Main aapki billing se judi queries mein madad kar sakti hoon. Bataiye, kya help chahiye?"
)
server = AgentServer()
def prewarm(proc: JobProcess):
proc.userdata["vad"] = silero.VAD.load()
server.setup_fnc = prewarm
@server.rtc_session()
async def entrypoint(ctx: JobContext):
ctx.log_context_fields = {"room": ctx.room.name}
session = AgentSession(
stt=murf.STT(
model="finch_indic_1.0",
language="hi,en_IN",
sample_rate=16000,
keywords=["EMI", "NACH", "autopay", "Murf Finance"],
alpha=0.6,
text_formatting=True,
),
llm="openai/gpt-4o",
tts=murf.TTS(
voice="Pooja",
style="Conversational",
speed=5,
pitch=0,
model="falcon-2.1",
sample_rate=24000,
locale="hi-IN",
),
vad=ctx.proc.userdata["vad"],
preemptive_generation=True,
resume_false_interruption=True,
false_interruption_timeout=1.0,
)
usage_collector = metrics.UsageCollector()
@session.on("metrics_collected")
def on_metrics(ev: MetricsCollectedEvent):
metrics.log_metrics(ev.metrics)
usage_collector.collect(ev.metrics)
async def log_usage():
summary = usage_collector.get_summary()
logger.info(f"Session usage: {summary}")
ctx.add_shutdown_callback(log_usage)
await session.start(
agent=CustomAgent(),
room=ctx.room,
room_options=room_io.RoomOptions(
audio_input=room_io.AudioInputOptions()
),
)
if __name__ == "__main__":
cli.run_app(server)

💡 Try it out: For complete working examples and deployment guides, see the livekit-murf repository.

Features

The Murf integration for LiveKit Agents provides a comprehensive set of features for building voice applications:

  • High-Quality Voice Generation: Leverage Murf’s advanced TTS technology with access to over 150 voices across 35+ languages
  • Real-time Transcription: Stream the caller’s audio to Finch for interim and final transcripts, with word-level timestamps and keyword boosting
  • Real-time Streaming: WebSocket-based streaming for low-latency audio generation, perfect for interactive conversations
  • Voice Customization: Control voice style, rate and pitch to match your application’s needs
  • Multi-Language Support: Multiple languages and locales with native speaker quality
  • Agent Framework Integration: Seamless integration with LiveKit’s Agent framework for building conversational AI
  • Flexible Configuration: Comprehensive audio format and quality options including sample rate, channel type, and output formats

Available Voices

Support

If you encounter any issues or have questions: