{"message": "Error in _stt_task\nTraceback (most r...
# ask-ai
h
{"message": "Error in _stt_task\nTraceback (most recent call last):\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/stt/stt.py\", line 408, in __anext__\n val = await self._event_aiter.__anext__()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nStopAsyncIteration\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/utils/log.py\", line 16, in async_fn_logs\n return await fn(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/voice/audio_recognition.py\", line 578, in _stt_task\n async for ev in node:\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/voice/agent.py\", line 376, in stt_node\n async for event in stream:\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/stt/stt.py\", line 411, in __anext__\n raise exc # noqa: B904\n ^^^^^^^^^\n File \"/app/.venv/lib/python3.12/site-packages/livekit/agents/stt/stt.py\", line 289, in _main_task\n return await self._run()\n ^^^^^^^^^^^^^^^^^\n File \"/app/.venv/lib/python3.12/site-packages/livekit/plugins/azure/stt.py\", line 217, in _run\n self._recognizer = _create_speech_recognizer(config=self._opts, stream=self._stream)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/app/.venv/lib/python3.12/site-packages/livekit/plugins/azure/stt.py\", line 358, in _create_speech_recognizer\n speech_config = speechsdk.SpeechConfig(\n ^^^^^^^^^^^^^^^^^^^^^^^\n File \"/app/.venv/lib/python3.12/site-packages/azure/cognitiveservices/speech/speech.py\", line 64, in __init__\n raise ValueError('cannot construct SpeechConfig with both region and endpoint or host information')\nValueError: cannot construct SpeechConfig with both region and endpoint or host information", "level": "ERROR", "name": "livekit.agents", "pid": 27, "job_id": "AJ_x7jjVyjfEkDi", "timestamp": "2025-11-17T094117.213259+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.
The error happens because both
speech_region
and
speech_endpoint
(or
speech_host
) are being set at the same time, which can cause a conflict. Let's work through this together to get it sorted: • If you're using a custom endpoint, just set
speech_endpoint
and leave out
speech_region
. • If you're working with a standard Azure region, set
speech_region
and skip
speech_endpoint
. • For Docker or local containers, use only
speech_host
without
speech_region
or
speech_endpoint
. • Also, double-check that environment variables like
AZURE_SPEECH_REGION
and
AZURE_SPEECH_ENDPOINT
aren’t conflicting with what you have in your code. If anything’s unclear or you’d like some help tailoring this to your setup, just let me know—I’m here to help! Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | Azure Speech STT plugin guide | LiveKit Docs
h
ok and what cases do i need to give key ?
t
You’ll want to provide a speech_key in these situations: • If you’re using Azure’s standard key-and-region authentication, both
speech_key
and
speech_region
are necessary. • If you have a custom
speech_endpoint
, you’ll still need to include
speech_key
unless your endpoint manages authentication on its own. On the other hand, you don’t need to provide a speech_key when: • You’re working with
speech_host
for containerized or private deployments. • You’re using
speech_auth_token
together with
speech_region
. If anything feels unclear or you’d like a hand setting things up, please don’t hesitate to reach out—I’m here to help! Sources: Azure Speech STT plugin guide | LiveKit Docs | livekit-plugins/livekit-plugins-soniox/README.md