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
1// prepare your openAI API key
2const openaiApiKey = 'API_KEY';
3
4// prepare the url player request and parameters
5const urlPlayerRequest = {
6 method: URLPlayerRequestMethod.POST,
7 url: 'https://api.openai.com/v1/audio/speech',
8 headers: [
9 { name: 'Authorization', value: 'Bearer ' + openaiApiKey },
10 { name: 'Content-Type', value: 'application/json' }
11 ],
12 body: {
13 text: JSON.stringify({
14 model: 'tts-1',
15 input: 'Today is a wonderful day to build something people love!',
16 voice: 'alloy'
17 })
18 }
19};
20
21const urlPlayerParameters = {
22 progressivePlayback: true
23};
24
25// create the url player
26player = VoxEngine.createURLPlayer(urlPlayerRequest, urlPlayerParameters);
27
28// send the generated audio to the call
29player.sendMediaTo(call);

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

See also