microsoft/semantic-kernel · error · ServiceInitializationError

The Azure OpenAI text to audio deployment name is required.

Error message

The Azure OpenAI text to audio deployment name is required.

What it means

Raised by AzureTextToAudio.__init__ after settings creation succeeds but text_to_audio_deployment_name is empty or None. This field is sourced from the deployment_name constructor argument or the AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME environment variable. The service needs a deployment name to know which TTS model to target.

Source

Thrown at python/semantic_kernel/connectors/ai/open_ai/services/azure_text_to_audio.py:79

                environment variables. (Optional)
            env_file_encoding: The encoding of the environment settings file. (Optional)
            credential: The credential to use for authentication. (Optional)
        """
        try:
            azure_openai_settings = AzureOpenAISettings(
                env_file_path=env_file_path,
                env_file_encoding=env_file_encoding,
                api_key=api_key,
                text_to_audio_deployment_name=deployment_name,
                endpoint=endpoint,
                base_url=base_url,
                api_version=api_version,
                token_endpoint=token_endpoint,
            )
        except ValidationError as exc:
            raise ServiceInitializationError(f"Invalid settings: {exc}") from exc
        if not azure_openai_settings.text_to_audio_deployment_name:
            raise ServiceInitializationError("The Azure OpenAI text to audio deployment name is required.")

        super().__init__(
            deployment_name=azure_openai_settings.text_to_audio_deployment_name,
            endpoint=azure_openai_settings.endpoint,
            base_url=azure_openai_settings.base_url,
            api_version=azure_openai_settings.api_version,
            service_id=service_id,
            api_key=azure_openai_settings.api_key.get_secret_value() if azure_openai_settings.api_key else None,
            ad_token=ad_token,
            ad_token_provider=ad_token_provider,
            token_endpoint=azure_openai_settings.token_endpoint,
            default_headers=default_headers,
            ai_model_type=OpenAIModelTypes.TEXT_TO_AUDIO,
            client=async_client,
            credential=credential,
        )

    @classmethod

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Pass deployment_name= explicitly: AzureTextToAudio(deployment_name='tts', ...).
  2. Set AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME in your environment or .env file.
  3. Verify the deployment exists in Azure Portal and the name matches exactly.

Example fix

# before
service = AzureTextToAudio(
    endpoint='https://myresource.openai.azure.com',
    api_key='...',
)
# after
service = AzureTextToAudio(
    deployment_name='tts',
    endpoint='https://myresource.openai.azure.com',
    api_key='...',
)
Defensive patterns

Strategy: validation

Validate before calling

import os

deployment_name = os.environ.get('AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME')
if not deployment_name:
    raise ValueError(
        'AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME is not set. '
        'Set it in your environment or .env file, or pass deployment_name= to the constructor.'
    )

Try / catch

from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError

try:
    service = AzureTextToAudio(
        deployment_name=os.environ.get('AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME'),
        endpoint='https://myresource.openai.azure.com',
        api_key='...',
    )
except ServiceInitializationError as e:
    if 'text to audio deployment name is required' in str(e):
        print('Set AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME or pass deployment_name=')
    raise

Prevention

When it happens

Trigger: Constructing AzureTextToAudio without deployment_name= and without AZURE_OPENAI_TEXT_TO_AUDIO_DEPLOYMENT_NAME in the environment or .env file. Endpoint and auth resolved, but the deployment identifier is absent.

Common situations: Using a chat or embedding deployment variable instead of the text-to-audio-specific one; TTS deployment created in Azure but env var not configured; .env file missing the text_to_audio line; fresh deployment environment.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/e4395b27a5d52e3f. Report an issue: GitHub.