#Text to speech with advanced voice
1 messages · Page 1 of 1 (latest)
Hi @acoustic veldt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
OpenAI's Text-to-Speech (TTS) API allows you to generate high-quality spoken audio from text. Currently, the TTS API offers six preset voices: alloy, echo, fable, onyx, nova, and shimmer. These voices are optimized for English and can be used to narrate a written blog post, produce spoken audio in multiple languages, or give real-time audio output using streaming.
However, as of the information available in the provided knowledge sources, the advanced voices with emotional capabilities that OpenAI demoed are not yet available via the API. The release date for these advanced voices has not been specified.
Here is an example of how to use the TTS API with the available voices:
from pathlib import Path
from openai import OpenAI
client = OpenAI()
speech_file_path = Path(__file__).parent / "speech.mp3"
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="Today is a wonderful day to build something people love!"
)
response.stream_to_file(speech_file_path)
In this example, the model parameter is set to "tts-1", the voice parameter is set to "alloy", and the input parameter is the text that you want to convert to speech. The resulting audio is saved as an MP3 file.
For more information, you can refer to the OpenAI Text-to-Speech Guide (https://platform.openai.com/docs/guides/text-to-speech) and the OpenAI API Reference (https://platform.openai.com/docs/api-reference).
Sources:
- OpenAI Text-to-Speech Guide (https://platform.openai.com/docs/guides/text-to-speech)
- OpenAI API Reference (https://platform.openai.com/docs/api-reference)
- OpenAI Community Post: Creating text to speech audio with openai turbo4o API (https://community.openai.com/t/846704)
- OpenAI Community Post: TTS New Voice with Emotional Capability (https://community.openai.com/t/868651)