Create speech
audio.speech.create(SpeechCreateParams**kwargs) -> BinaryResponseContent
POST/audio/speech
Generates audio from the input text.
Parameters
input: str
The text to generate audio for. The maximum length is 4096 characters.
maxLength4096
instructions: Optional[str]
Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.
maxLength4096
speed: Optional[float]
The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.
minimum0.25
maximum4
Returns
BinaryResponseContent
Create speech
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
speech = client.audio.speech.create(
input="input",
model="string",
voice="ash",
)
print(speech)
content = speech.read()
print(content)