OpenAI TTS voices

Use OpenAI text-to-speech voices with Voximplant.

View as Markdown

OpenAI, the organization that specializes in artificial intelligence researches, in addition to ChatGPT, provides realistic text-to-speech voices, that you can use easily with your Voximplant application.

Setup

The only requirement to use the Open AI voices with Voximplant applications is having an Open AI account and have a working API key.

After you receive an API key, to use the voices, create a URL player in your VoxEngine scenario and prepare a POST request as it is explained in the Media players guide.

Take a look at the following example with comments:

Using OpenAI TTS
// prepare your openAI API key
const openaiApiKey = 'API_KEY';
// prepare the url player request and parameters
const urlPlayerRequest = {
method: URLPlayerRequestMethod.POST,
url: 'https://api.openai.com/v1/audio/speech',
headers: [
{ name: 'Authorization', value: 'Bearer ' + openaiApiKey },
{ name: 'Content-Type', value: 'application/json' }
],
body: {
text: JSON.stringify({
model: 'tts-1',
input: 'Today is a wonderful day to build something people love!',
voice: 'alloy'
})
}
};
const urlPlayerParameters = {
progressivePlayback: true
};
// create the url player
player = VoxEngine.createURLPlayer(urlPlayerRequest, urlPlayerParameters);
// send the generated audio to the call
player.sendMediaTo(call);

To modify the voice parameters, modify the body of your URL player request according to the OpenAI TTS documentation.

See also