Create speech
client.Audio.Speech.New(ctx, body) (*Response, error)
POST/audio/speech
Generates audio from the input text.
Parameters
Returns
type AudioSpeechNewResponse interface{…}
Create speech
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
speech, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{
Input: "input",
Model: openai.SpeechModelTTS1,
Voice: openai.AudioSpeechNewParamsVoiceAsh,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", speech)
}