diff --git a/docs/my-website/docs/providers/vertex.md b/docs/my-website/docs/providers/vertex.md index 1e4f106a7..582636630 100644 --- a/docs/my-website/docs/providers/vertex.md +++ b/docs/my-website/docs/providers/vertex.md @@ -1843,13 +1843,15 @@ print("response from proxy", response) ### Usage - `ssml` as input +Pass your `ssml` as input to the `input` param, if it contains ``, it will be automatically detected and passed as `ssml` to the Vertex AI API + +If you need to force your `input` to be passed as `ssml`, set `use_ssml=True` 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" @@ -1863,9 +1865,8 @@ ssml = """ """ response = litellm.speech( - input=None, + input=ssml, model="vertex_ai/test", - ssml=ssml, voice={ "languageCode": "en-UK", "name": "en-UK-Studio-O", @@ -1898,11 +1899,8 @@ ssml = """ # 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 + input=ssml, voice={'languageCode': 'en-US', 'name': 'en-US-Studio-O'}, - extra_body={ - "ssml": ssml - } ) print("response from proxy", response) ``` @@ -1911,6 +1909,81 @@ print("response from proxy", response) +### Forcing SSML Usage + +You can force the use of SSML by setting the `use_ssml` parameter to `True`. This is useful when you want to ensure that your input is treated as SSML, even if it doesn't contain the `` tags. + +Here are examples of how to force SSML usage: + + + + + +Vertex AI does not support passing a `model` param - so passing `model=vertex_ai/` is the only required param + + +```python +speech_file_path = Path(__file__).parent / "speech_vertex.mp3" + + +ssml = """ + +

Hello, world!

+

This is a test of the text-to-speech API.

+
+""" + +response = litellm.speech( + input=ssml, + use_ssml=True, + model="vertex_ai/test", + 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") + +ssml = """ + +

Hello, world!

+

This is a test of the text-to-speech API.

+
+""" + +# 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=ssml, # pass as None since OpenAI SDK requires this param + voice={'languageCode': 'en-US', 'name': 'en-US-Studio-O'}, + extra_body={"use_ssml": True}, +) +print("response from proxy", response) +``` + +
+
+ + + + + + ## Extra