diff --git a/litellm/llms/ovhcloud/audio_transcription/transformation.py b/litellm/llms/ovhcloud/audio_transcription/transformation.py index 7ff6dc986be..f7abefed6ef 100644 --- a/litellm/llms/ovhcloud/audio_transcription/transformation.py +++ b/litellm/llms/ovhcloud/audio_transcription/transformation.py @@ -156,5 +156,10 @@ class OVHCloudAudioTranscriptionConfig(BaseAudioTranscriptionConfig): text = response_json.get("text") or response_json.get("transcript") or "" response = TranscriptionResponse(text=text) + if "segments" in response_json: + response["segments"] = response_json["segments"] + if "language" in response_json: + response["language"] = response_json["language"] + response._hidden_params = response_json return response diff --git a/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py b/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py index fc5e310e71b..ff0173fab94 100644 --- a/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py +++ b/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py @@ -7,10 +7,14 @@ import pytest from litellm.llms.base_llm.audio_transcription.transformation import ( BaseAudioTranscriptionConfig, ) +from litellm.llms.ovhcloud.audio_transcription.transformation import OVHCloudAudioTranscriptionConfig +from litellm.types.utils import TranscriptionResponse from litellm.utils import ProviderConfigManager from tests.llm_translation.base_audio_transcription_unit_tests import ( BaseLLMAudioTranscriptionTest, ) +from unittest.mock import MagicMock +import httpx @pytest.mark.skipif( @@ -55,5 +59,39 @@ def test_ovhcloud_audio_transcription_config_installed(): assert config is not None assert isinstance(config, BaseAudioTranscriptionConfig) +def test_ovhcloud_audio_transcription_response_transform_diarized(): + """Test that diarized responses preserve segments and language.""" + config = OVHCloudAudioTranscriptionConfig() + mock_response = MagicMock(spec=httpx.Response) + mock_response.json.return_value = { + "text": "Hello, how are you? I am fine.", + "language": "en", + "segments": [ + { + "text": "Hello, how are you?", + "start": 0.3, + "end": 2.1 + }, + { + "text": "I am fine.", + "start": 2.5, + "end": 3.8 + }, + ], + "usage": { + "type": "duration", + "duration": 5, + "seconds": 5, + }, + } + response = config.transform_audio_transcription_response(mock_response) + + assert isinstance(response, TranscriptionResponse) + assert response.text == "Hello, how are you? I am fine." + assert response["segments"] is not None + assert len(response["segments"]) == 2 + assert response["segments"][0]["text"] == "Hello, how are you?" + assert response["segments"][1]["text"] == "I am fine." + assert response["language"] == "en" \ No newline at end of file