The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
add ssml input on vertex tts
Ishaan Jaff6d11b392f878
diff --git a/litellm/llms/text_to_speech/vertex_ai.py b/litellm/llms/text_to_speech/vertex_ai.pyindex b9fca53250d..0b6b9deb8b1 100644--- a/litellm/llms/text_to_speech/vertex_ai.py+++ b/litellm/llms/text_to_speech/vertex_ai.py@@ -19,7 +19,8 @@ from litellm.llms.vertex_ai_and_google_ai_studio.vertex_and_google_ai_studio_gemclass VertexInput(TypedDict, total=False):- text: str+ text: Optional[str]+ ssml: Optional[str]class VertexVoice(TypedDict, total=False):@@ -86,10 +87,11 @@ class VertexTextToSpeechAPI(VertexLLM):####### Build the request ################# API Ref: https://cloud.google.com/text-to-speech/docs/reference/rest/v1/text/synthesize- vertex_input = VertexInput(text=input)+ kwargs = kwargs or {}+ vertex_input = VertexInput(text=input, ssml=kwargs.get("ssml", None))+ validate_vertex_input(vertex_input)# required paramoptional_params = optional_params or {}- kwargs = kwargs or {}if voice is not None:vertex_voice = VertexVoice(**voice)elif "voice" in kwargs:@@ -203,3 +205,12 @@ class VertexTextToSpeechAPI(VertexLLM):# Initialize the HttpxBinaryResponseContent instancehttp_binary_response = HttpxBinaryResponseContent(response)return http_binary_response+++def validate_vertex_input(input_data: VertexInput) -> None:+ if input_data.get("text", None) is None:+ input_data.pop("text")+ if "text" not in input_data and "ssml" not in input_data:+ raise ValueError("Either 'text' or 'ssml' must be provided.")+ if "text" in input_data and "ssml" in input_data:+ raise ValueError("Only one of 'text' or 'ssml' should be provided, not both.")