fix(azure): address speech transcription review

Co-authored-by: ishaan-berri <ishaan-berri@users.noreply.github.com>
This commit is contained in:
oss-agent-shin 2026-05-09 00:02:17 +00:00
parent 7d3f03ad4b
commit 2e5d70570e
No known key found for this signature in database
4 changed files with 43 additions and 1 deletions

View file

@ -5652,6 +5652,7 @@
"source": "https://azure.microsoft.com/en-us/pricing/calculator/"
},
"azure/speech/azure-stt": {
"audio_transcription_config": "azure_speech",
"input_cost_per_second": 0.0002777778,
"litellm_provider": "azure",
"mode": "audio_transcription",

View file

@ -8060,6 +8060,35 @@ def validate_openai_optional_params(
return stop
@lru_cache(maxsize=1)
def _get_bundled_model_cost_map() -> Dict[str, Any]:
try:
model_cost_path = resources.files("litellm").joinpath(
"model_prices_and_context_window_backup.json"
)
return json.loads(model_cost_path.read_text())
except Exception:
return {}
def _get_model_cost_entry_for_provider_config(
model: str,
provider: LlmProviders,
) -> Dict[str, Any]:
candidate_keys = (model, f"{provider.value}/{model}")
for model_key in candidate_keys:
model_info = litellm.model_cost.get(model_key)
if model_info is not None:
return model_info
bundled_model_cost = _get_bundled_model_cost_map()
for model_key in candidate_keys:
model_info = bundled_model_cost.get(model_key)
if model_info is not None:
return model_info
return {}
class ProviderConfigManager:
# Dictionary mapping for O(1) provider lookup
# Stores tuples of (factory_function, needs_model_parameter)
@ -8500,7 +8529,14 @@ class ProviderConfigManager:
model: str,
provider: LlmProviders,
) -> Optional[BaseAudioTranscriptionConfig]:
if litellm.LlmProviders.AZURE == provider and model.startswith("speech/"):
model_cost_entry = _get_model_cost_entry_for_provider_config(
model=model,
provider=provider,
)
if (
litellm.LlmProviders.AZURE == provider
and model_cost_entry.get("audio_transcription_config") == "azure_speech"
):
from litellm.llms.azure.audio_transcription.transformation import (
AzureSpeechAudioTranscriptionConfig,
)

View file

@ -5652,6 +5652,7 @@
"source": "https://azure.microsoft.com/en-us/pricing/calculator/"
},
"azure/speech/azure-stt": {
"audio_transcription_config": "azure_speech",
"input_cost_per_second": 0.0002777778,
"litellm_provider": "azure",
"mode": "audio_transcription",

View file

@ -215,3 +215,7 @@ def test_azure_speech_stt_has_non_zero_input_pricing():
pricing = json.loads(pricing_path.read_text())
assert pricing["azure/speech/azure-stt"]["input_cost_per_second"] > 0
assert (
pricing["azure/speech/azure-stt"]["audio_transcription_config"]
== "azure_speech"
)