From 658beda2ba8be4d155bc62208224a5766e0640c0 Mon Sep 17 00:00:00 2001 From: netr Date: Sat, 26 Apr 2025 03:13:43 -0700 Subject: [PATCH] feat: Add missing TTS models and voices (#958) * feat: Add missing TTS models and voices * feat: Add new instruction field to create speech request - From docs: Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd. * fix: add canary-tts back to SpeechModel --- speech.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/speech.go b/speech.go index 20b52e3..60e7694 100644 --- a/speech.go +++ b/speech.go @@ -8,20 +8,25 @@ import ( type SpeechModel string const ( - TTSModel1 SpeechModel = "tts-1" - TTSModel1HD SpeechModel = "tts-1-hd" - TTSModelCanary SpeechModel = "canary-tts" + TTSModel1 SpeechModel = "tts-1" + TTSModel1HD SpeechModel = "tts-1-hd" + TTSModelCanary SpeechModel = "canary-tts" + TTSModelGPT4oMini SpeechModel = "gpt-4o-mini-tts" ) type SpeechVoice string const ( VoiceAlloy SpeechVoice = "alloy" + VoiceAsh SpeechVoice = "ash" + VoiceBallad SpeechVoice = "ballad" + VoiceCoral SpeechVoice = "coral" VoiceEcho SpeechVoice = "echo" VoiceFable SpeechVoice = "fable" VoiceOnyx SpeechVoice = "onyx" VoiceNova SpeechVoice = "nova" VoiceShimmer SpeechVoice = "shimmer" + VoiceVerse SpeechVoice = "verse" ) type SpeechResponseFormat string @@ -39,6 +44,7 @@ type CreateSpeechRequest struct { Model SpeechModel `json:"model"` Input string `json:"input"` Voice SpeechVoice `json:"voice"` + Instructions string `json:"instructions,omitempty"` // Optional, Doesnt work with tts-1 or tts-1-hd. ResponseFormat SpeechResponseFormat `json:"response_format,omitempty"` // Optional, default to mp3 Speed float64 `json:"speed,omitempty"` // Optional, default to 1.0 }