Skip to content

OpenAI.AudioGeneration

Andrew Lambert edited this page Jul 14, 2024 · 7 revisions

OpenAI.AudioGeneration

Class Declaration

 Protected Class AudioGeneration
 Inherits OpenAI.Response

Remarks

This class represents an API Text-to-Speech (TTS) response. Refer to the OpenAI documentation on the /v1/audio/speech endpoint for further details.

Example

This example uploads some text and downloads the spoken version as an MP3:

 OpenAI.APIKey = "YOUR API KEY"
 Dim data As String = "This is a test. This is a test of the OpenAI API. This is only a test."
 Dim response As OpenAI.Response = OpenAI.AudioGeneration.Create(data, "tts-1", "alloy")
 Dim audio As MemoryBlock = response.GetResult()

This example does the same as the previous example, but asks for the raw audio data only:

 OpenAI.APIKey = "YOUR API KEY"
 Dim data As String = "This is a test. This is a test of the OpenAI API. This is only a test."
 Dim audio As MemoryBlock = OpenAI.AudioGeneration.CreateRaw(data, "tts-1", "alloy")

Methods

Properties

Shared methods

Shared properties

Clone this wiki locally