From 043919b27856c63b59c92c14f4e34fdc0d38c5f9 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Wed, 28 Aug 2024 12:27:44 -0700 Subject: [PATCH] use ssml with litellm vertex --- docs/my-website/docs/providers/vertex.md | 57 +++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/docs/my-website/docs/providers/vertex.md b/docs/my-website/docs/providers/vertex.md index 697aa0701ed..8912133b8b5 100644 --- a/docs/my-website/docs/providers/vertex.md +++ b/docs/my-website/docs/providers/vertex.md @@ -1768,7 +1768,7 @@ LiteLLM supports calling [Vertex AI Text to Speech API](https://console.cloud.go -Usage +### Usage - Basic @@ -1841,6 +1841,61 @@ print("response from proxy", response) +### Usage - `ssml` as input + + + + + +Vertex AI does not support passing a `model` param - so passing `model=vertex_ai/` is the only required param + +**Sync Usage** + +```python +speech_file_path = Path(__file__).parent / "speech_vertex.mp3" +response = litellm.speech( + input=None, + model="vertex_ai/test", + ssml="async hello what llm guardrail do you have", + voice={ + "languageCode": "en-UK", + "name": "en-UK-Studio-O", + }, + audioConfig={ + "audioEncoding": "LINEAR22", + "speakingRate": "10", + }, +) +response.stream_to_file(speech_file_path) +``` + + + + + +```python +import openai + +client = openai.OpenAI(api_key="sk-1234", base_url="http://0.0.0.0:4000") + +# see supported values for "voice" on vertex here: +# https://console.cloud.google.com/vertex-ai/generative/speech/text-to-speech +response = client.audio.speech.create( + model = "vertex-tts", + input=None, # pass as None since OpenAI SDK requires this param + voice={'languageCode': 'en-US', 'name': 'en-US-Studio-O'}, + extra_body={ + "ssml": "async hello what llm guardrail do you have" + } +) +print("response from proxy", response) +``` + + + + + + ## Extra ### Using `GOOGLE_APPLICATION_CREDENTIALS`