mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-10 08:05:22 +02:00
feat: add Azure AI multi-provider support (TTS, STT, Embeddings, Realtime)
Enables Azure AI services across all model layers so users with Azure credits can consolidate billing on a single provider. - Voice (TTS): AzureSpeechTTSConfiguration via azure_speech provider - Transcriber (STT): AzureSpeechSTTConfiguration via azure_speech provider - Embedding: AzureOpenAIEmbeddingsConfiguration via azure provider - Realtime: AzureRealtimeLLMConfiguration via azure_realtime provider New files: - api/services/pipecat/realtime/azure_realtime.py - api/services/gen_ai/embedding/azure_openai_service.py - api/tests/test_azure_speech_service_factory.py The UI picks up all four providers automatically from the schema — no frontend changes required. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e695436fb3
commit
dbbf362315
12 changed files with 883 additions and 28 deletions
81
api/tests/test_azure_speech_service_factory.py
Normal file
81
api/tests/test_azure_speech_service_factory.py
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
"""Tests for Azure Speech TTS/STT service factory dispatch."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
from api.services.configuration.registry import ServiceProviders
|
||||
from api.services.pipecat.service_factory import create_stt_service, create_tts_service
|
||||
|
||||
|
||||
def _audio_config():
|
||||
return SimpleNamespace(
|
||||
transport_out_sample_rate=24000,
|
||||
transport_in_sample_rate=16000,
|
||||
)
|
||||
|
||||
|
||||
def test_create_azure_speech_tts_service():
|
||||
user_config = SimpleNamespace(
|
||||
tts=SimpleNamespace(
|
||||
provider=ServiceProviders.AZURE_SPEECH.value,
|
||||
api_key="test-subscription-key",
|
||||
region="eastus",
|
||||
voice="en-US-AriaNeural",
|
||||
language="en-US",
|
||||
speed=1.0,
|
||||
model="neural",
|
||||
)
|
||||
)
|
||||
|
||||
with patch("api.services.pipecat.service_factory.AzureTTSService") as mock_service:
|
||||
create_tts_service(user_config, _audio_config())
|
||||
|
||||
assert mock_service.call_count == 1
|
||||
kwargs = mock_service.call_args.kwargs
|
||||
assert kwargs["api_key"] == "test-subscription-key"
|
||||
assert kwargs["region"] == "eastus"
|
||||
assert kwargs["settings"].voice == "en-US-AriaNeural"
|
||||
assert kwargs["settings"].language == "en-US"
|
||||
|
||||
|
||||
def test_create_azure_speech_tts_service_with_speed():
|
||||
user_config = SimpleNamespace(
|
||||
tts=SimpleNamespace(
|
||||
provider=ServiceProviders.AZURE_SPEECH.value,
|
||||
api_key="test-key",
|
||||
region="westeurope",
|
||||
voice="en-GB-SoniaNeural",
|
||||
language="en-GB",
|
||||
speed=1.5,
|
||||
model="neural",
|
||||
)
|
||||
)
|
||||
|
||||
with patch("api.services.pipecat.service_factory.AzureTTSService") as mock_service:
|
||||
create_tts_service(user_config, _audio_config())
|
||||
|
||||
assert mock_service.call_count == 1
|
||||
kwargs = mock_service.call_args.kwargs
|
||||
assert kwargs["region"] == "westeurope"
|
||||
assert kwargs["settings"].rate == "1.5"
|
||||
|
||||
|
||||
def test_create_azure_speech_stt_service():
|
||||
user_config = SimpleNamespace(
|
||||
stt=SimpleNamespace(
|
||||
provider=ServiceProviders.AZURE_SPEECH.value,
|
||||
api_key="test-subscription-key",
|
||||
region="eastus",
|
||||
language="en-US",
|
||||
model="latest_long",
|
||||
)
|
||||
)
|
||||
|
||||
with patch("api.services.pipecat.service_factory.AzureSTTService") as mock_service:
|
||||
create_stt_service(user_config, _audio_config())
|
||||
|
||||
assert mock_service.call_count == 1
|
||||
kwargs = mock_service.call_args.kwargs
|
||||
assert kwargs["api_key"] == "test-subscription-key"
|
||||
assert kwargs["region"] == "eastus"
|
||||
assert kwargs["sample_rate"] == 16000
|
||||
Loading…
Add table
Add a link
Reference in a new issue