Azure Text to Speech (tts)
Overviewโ
Property | Details |
---|---|
Description | Convert text to natural-sounding speech using Azure OpenAI's Text to Speech models |
Provider Route on LiteLLM | azure/ |
Supported Operations | /audio/speech |
Link to Provider Doc | Azure OpenAI TTS โ |
Quick Startโ
LiteLLM SDKโ
SDK Usage
from litellm import speech
from pathlib import Path
import os
## set ENV variables
os.environ["AZURE_API_KEY"] = ""
os.environ["AZURE_API_BASE"] = ""
os.environ["AZURE_API_VERSION"] = ""
# azure call
speech_file_path = Path(__file__).parent / "speech.mp3"
response = speech(
model="azure/<your-deployment-name>",
voice="alloy",
input="the quick brown fox jumped over the lazy dogs",
)
response.stream_to_file(speech_file_path)
LiteLLM PROXYโ
proxy_config.yaml
model_list:
- model_name: azure/tts-1
litellm_params:
model: azure/tts-1
api_base: "os.environ/AZURE_API_BASE_TTS"
api_key: "os.environ/AZURE_API_KEY_TTS"
api_version: "os.environ/AZURE_API_VERSION"
Available Voicesโ
Azure OpenAI supports the following voices:
alloy
- Neutral and balancedecho
- Warm and upbeatfable
- Expressive and dramaticonyx
- Deep and authoritativenova
- Friendly and conversationalshimmer
- Bright and cheerful
Supported Parametersโ
All Parameters
response = speech(
model="azure/<your-deployment-name>",
voice="alloy", # Required: Voice selection
input="text to convert", # Required: Input text
speed=1.0, # Optional: 0.25 to 4.0 (default: 1.0)
response_format="mp3" # Optional: mp3, opus, aac, flac, wav, pcm
)
Supported Modelsโ
tts-1
- Standard quality, optimized for speedtts-1-hd
- High definition, optimized for quality
Use your Azure deployment name: azure/<your-deployment-name>