chore: import upstream snapshot with attribution
CodeQL / Analyze (csharp) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:21:23 +08:00
commit b957a53def
5423 changed files with 863745 additions and 0 deletions
@@ -0,0 +1,49 @@
# Copyright (c) Microsoft. All rights reserved.
import pytest
from semantic_kernel.connectors.ai.text_to_audio_client_base import TextToAudioClientBase
from semantic_kernel.contents import AudioContent
from tests.integration.text_to_audio.text_to_audio_test_base import TextToAudioTestBase, azure_setup
pytestmark = pytest.mark.parametrize(
"service_id, text",
[
pytest.param(
"openai",
"Hello World!",
id="openai",
),
pytest.param(
"azure_openai",
"Hello World!",
marks=pytest.mark.skipif(not azure_setup, reason="Azure Audio to Text not setup."),
id="azure_openai",
),
],
)
class TestTextToAudio(TextToAudioTestBase):
"""Test text-to-audio services."""
async def test_audio_to_text(
self,
services: dict[str, TextToAudioClientBase],
service_id: str,
text: str,
) -> None:
"""Test text-to-audio services.
Args:
services: text-to-audio services.
service_id: Service ID.
text: Text content.
"""
service = services[service_id]
result = await service.get_audio_content(text)
assert isinstance(result, AudioContent)
assert result.data is not None
@@ -0,0 +1,30 @@
# Copyright (c) Microsoft. All rights reserved.
import os
import pytest
from azure.identity import AzureCliCredential
from semantic_kernel.connectors.ai.open_ai import AzureTextToAudio, OpenAITextToAudio
from semantic_kernel.connectors.ai.text_to_audio_client_base import TextToAudioClientBase
from tests.utils import is_service_setup_for_testing
# TTS model on Azure model is not available in regions at which we have chat completion models.
# Therefore, we need to use a different endpoint for testing.
azure_setup = is_service_setup_for_testing(["AZURE_OPENAI_TEXT_TO_AUDIO_ENDPOINT"])
class TextToAudioTestBase:
"""Base class for testing text-to-audio services."""
@pytest.fixture(scope="module")
def services(self) -> dict[str, TextToAudioClientBase]:
"""Return text-to-audio services."""
return {
"openai": OpenAITextToAudio(),
"azure_openai": AzureTextToAudio(
endpoint=os.environ["AZURE_OPENAI_TEXT_TO_AUDIO_ENDPOINT"], credential=AzureCliCredential()
)
if azure_setup
else None,
}