most-vr-18651
10/27/2025, 2:12 PMtall-airline-16756
10/27/2025, 2:12 PMtall-airline-16756
10/27/2025, 2:14 PMbase_url, api_key, encoding, and sample_rate. Your endpoint should be ready to handle specific message types for session creation, audio input, and session finalization.
• TTS Configuration: For your TTS model, OpenAI-compatible endpoints work well. Set parameters such as base_url, model, and response_format. If you'd like, you can also create a custom TTS class to implement your own unique TTS logic.
• Authentication: Don’t forget to set up your API keys and secrets properly to keep everything secure.
• Audio Format: It’s important to specify the correct encoding (for example, pcm_s16le) and sample rate (like 16000 Hz) to ensure smooth audio processing.
If you’d like, I’m here to help with more detailed guidance or even code examples tailored to your setup—just let me know!
Sources: Baseten STT plugin guide | LiveKit Docs | Pipeline nodes and hooks | LiveKit Docs | Text-to-speech (TTS) models | LiveKit Docs | agents/src/inference/stt.ts | livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/models.pymost-vr-18651
10/27/2025, 2:23 PMtall-airline-16756
10/27/2025, 2:25 PM<BASE_API_URL>! You can easily configure LiveKit to use your endpoint. Here are some code examples crafted just for your setup to help you get started:
Custom STT Integration
If your endpoint supports WebSocket connections, here’s a simple way to set it up:
from livekit.plugins import openai
stt = openai.STT(
model="your-custom-model",
base_url=f"wss://{os.getenv('BASE_API_URL')}/transcribe", # WebSocket URL
api_key="your-api-key", # Replace with your key if required
encoding="pcm_s16le", # Make sure this matches your endpoint's expected format
sample_rate=16000, # Standard sample rate for audio
extra_kwargs={
"interim_results": True, # Enable interim transcription results
"punctuate": True # Add punctuation if supported
}
)
Custom TTS Integration
If your TTS endpoint is OpenAI-compatible, you can configure it like this:
from livekit.plugins import openai
tts = openai.TTS(
model="your-custom-model",
base_url=f"https://{os.getenv('BASE_API_URL')}/transcribe", # HTTP endpoint for TTS
response_format="wav", # Ensure this matches your endpoint's output format
api_key="your-api-key" # Replace with your key if required
)
Agent Session Example
And here’s a friendly example showing how to bring these configurations into your agent session:
from livekit.agents import AgentSession
session = AgentSession(
stt=stt, # Use the custom STT configuration
tts=tts, # Use the custom TTS configuration
llm=openai.LLM(model="gpt-4.1-mini"),
allow_interruptions=True
)
Just a quick reminder to double-check that your endpoint supports the required audio format (pcm_s16le, 16kHz) and any authentication needed. If you have any questions or want me to walk you through any part, please feel free to ask—I’m here to help!
Sources: Baseten STT plugin guide | LiveKit Docs | Models | LiveKit Docs | livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/stt.pymost-vr-18651
10/27/2025, 2:30 PMtall-airline-16756
10/27/2025, 2:31 PM/audio/transcriptions.
• Multipart Form Data: The request will include:
◦ `file`: The audio file (WAV format).
◦ `model`: The model name (for example, whisper-1).
◦ `language`: (Optional) ISO-639-1 language code.
◦ `response_format`: It should support json.
• Response Format: Your endpoint should return JSON like this: { "text": "This is a transcription." }
2. Example Integration with LiveKit
Once your endpoint is set up to be OpenAI-compatible, you can easily configure it in LiveKit like this:
from livekit.plugins import openai
stt = openai.STT(
base_url="https://your-custom-stt-service.com/v1", # Replace with your endpoint
api_key="your-api-key", # Optional, if your endpoint requires authentication
model="whisper-1",
language="en"
)
3. Key Considerations
• Audio Format: Be sure your endpoint accepts 16-bit PCM WAV audio at 16kHz or 24kHz.
• Authentication: If your endpoint needs it, validate the Authorization: Bearer <api_key> header properly.
• Timeouts: Try to ensure your endpoint responds within 30 seconds to avoid any timeouts.
4. Testing
Feel free to use your current test script to check how the endpoint behaves. Just make sure it returns the expected JSON response with a text field.
If you have any questions or run into any issues while implementing or debugging, please don’t hesitate to reach out — I’m here to help you every step of the way!
Sources: examples/frontdesk/frontdesk_agent.py | examples/src/anam_realtime_agent.ts | OpenAI STT plugin guide | LiveKit Docsmost-vr-18651
10/27/2025, 2:33 PMtall-airline-16756
10/27/2025, 2:34 PM/v1/audio/speech.
• Request Format: The request needs to include JSON parameters:
◦ `input`: The text you'd like to synthesize.
◦ `model`: The TTS model identifier you're using.
◦ `voice`: The voice profile identifier.
◦ `response_format`: The audio format you want back (like wav or mp3).
◦ `speed`: (Optional) The speech rate, for example 1.0.
◦ `instructions`: (Optional) Any voice style instructions you'd like to apply.
• Response Format: Your endpoint should return raw audio data in the requested format, along with the appropriate headers: Content-Type: audio/[format]
2. Example Integration with LiveKit
Once your endpoint is ready and OpenAI-compatible, you can set it up in LiveKit like this:
from livekit.plugins import openai
tts = openai.TTS(
model="your-custom-model",
voice="your-voice-id",
api_key="your-api-key-or-placeholder", # Use "not-needed" if no auth required
base_url="http://your-endpoint:port/v1", # Replace with your endpoint
response_format="wav" # or your preferred format
)
3. Key Considerations
• Audio Format: Make sure your endpoint outputs audio at 24kHz mono (or a format that LiveKit can decode).
• Authentication: If your endpoint requires it, validate the Authorization: Bearer <api_key> header.
• Error Handling: It's important to return appropriate HTTP status codes, like 200 for success and 400 for bad requests.
4. Testing
Before going live, test your deployment to confirm the endpoint behaves as expected and returns the audio in the requested format.
If you have any questions or need a hand with implementation or debugging, please don’t hesitate to reach out. I’m here to help!
Sources: livekit-plugins/livekit-plugins-baseten/livekit/plugins/baseten/tts.pymost-vr-18651
10/27/2025, 2:36 PMtall-airline-16756
10/27/2025, 2:38 PM/v1/audio/speech.
• Request Format: The endpoint needs to accept JSON parameters:
◦ `input`: The text you'd like to synthesize.
◦ `model`: The identifier for your TTS model.
◦ `voice`: The voice profile you'd like to use.
◦ `response_format`: The audio format you want back (for example, wav or mp3).
◦ `speed`: (Optional) Controls the speech rate, like 1.0 for normal speed.
◦ `instructions`: (Optional) Any voice style instructions you want to add.
• Response Format: Your endpoint should return the raw audio data in the requested format, with the right headers, like: Content-Type: audio/[format]
2. Adapting Your Deployment
It’s great that your deployment already initializes the model and synthesizes speech! To align it with OpenAI compatibility, here’s what you can do:
• Create an HTTP POST endpoint using FastAPI at /v1/audio/speech.
• Parse the incoming JSON request to extract parameters such as input, model, and voice.
• Use your existing generate_speech function to synthesize the audio based on the text input.
• Return the audio data as a binary response, making sure to set the Content-Type header properly (e.g., audio/wav).
3. Example FastAPI Endpoint
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from fastapi.responses import Response
app = FastAPI()
class TTSRequest(BaseModel):
input: str
model: str
voice: str
response_format: str = "wav"
speed: float = 1.0
@app.post("/v1/audio/speech")
async def synthesize_speech(request: TTSRequest):
try:
audio = generate_speech(
text=request.input,
speaker_id=request.voice,
max_tokens=12000,
temperature=0.6,
top_p=0.95
)
return Response(content=audio.tobytes(), media_type=f"audio/{request.response_format}")
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
4. LiveKit Integration
Once your endpoint is ready and OpenAI-compatible, you can configure it in LiveKit like this:
from livekit.plugins import openai
tts = openai.TTS(
model="your-model",
voice="your-voice",
base_url=f"https://{os.getenv('BASE_API_URL')}/v1", # Replace with your endpoint
response_format="wav"
)
If you have any questions or run into any bumps along the way, please don’t hesitate to reach out. I’m here to help you get this working perfectly!
Sources: livekit-plugins/livekit-plugins-upliftai/livekit/plugins/upliftai/tts.py | chain-of-thought-tts/README.mdoc | plugins/openai/src/tts.ts | OpenAI TTS plugin guide | LiveKit Docs