Could anyone help me out how to setup azure plugin...
# ask-ai
h
Could anyone help me out how to setup azure plugin for stt and tts I have azure speech services deployed and i am writing below conditions
Copy code
elif self.provider == "azure":
                azure_config = {
                    "language": self.language
                }
                speech_endpoint=os.getenv("AZURE_SPEECH_ENDPOINT")
                if speech_endpoint:
                    azure_config["speech_endpoint"] = speech_endpoint
                    azure_config["speech_key"] = os.getenv("AZURE_SPEECH_API_KEY")
                else:
                    azure_config["speech_key"] = os.getenv("AZURE_SPEECH_API_KEY")
                    azure_config["speech_region"] = os.getenv("AZURE_SPEECH_REGION")

                self.stt_service = azure.STT(
                    **azure_config
                )
now i set the endpoint and key in the env but i get this error
Copy code
{
  "message": "failed to synthesize speech, retrying in 0.1s\nTraceback (most recent call last):\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/tts/tts.py\", line 267, in _main_task\n raise APIError(f\"no audio frames were pushed for text: {self._input_text}\")\nlivekit.agents._exceptions.APIError: no audio frames were pushed for text: Hi, I am Arya, an AWS Engineer designed and developed by NTT DATA. (body=None, retryable=True)",
  "level": "WARNING",
  "name": "livekit.agents",
  "tts": "livekit.plugins.azure.tts.TTS",
  "attempt": 1,
  "streamed": false,
  "pid": 28,
  "job_id": "AJ_rJx8eDoYVaAi",
  "timestamp": "2025-11-17T10:34:32.689836+00:00"
}
t
Thanks for reaching out, Sahil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Let's get you set up with the Azure plugin for STT and TTS in LiveKit—I'll walk you through the steps: 1. First, install the plugin by running:
uv add "livekit-agents[azure]~=1.2"
2. Next, make sure to set the necessary environment variables in your
.env
file:
AZURE_SPEECH_KEY
,
AZURE_SPEECH_REGION
, and if you have it,
AZURE_SPEECH_ENDPOINT
. 3. Then, initialize the Azure STT and TTS plugins in your code like this:
Copy code
from livekit.plugins import azure

# Initialize STT
stt = azure.STT()

# Initialize TTS
tts = azure.TTS(voice="en-US-JennyNeural", sample_rate=24000)
About the error message "no audio frames were pushed for text," this usually means the Azure service didn’t generate any audio. Here are a few friendly tips to help you troubleshoot: • Double-check that your environment variables are correctly set and valid. • Try enabling detailed logging to get more insight:
Copy code
import logging
logging.basicConfig(level=logging.DEBUG)
• It can also help to test Azure TTS on its own, outside of LiveKit, using a simple script to send requests directly to Azure’s API. • Make sure your SSML input is valid and that the sample rate you’re using (like 24000 Hz) is supported. If you’re still running into trouble after these steps, just let me know—I’m here to help you figure it out together! Sources: Azure Speech STT plugin guide | LiveKit Docs | Azure Speech TTS plugin guide | LiveKit Docs | examples/voice_agents/error_callback.py