@@ -2,7 +2,6 @@ package openai
2
2
3
3
import (
4
4
"context"
5
- "errors"
6
5
"net/http"
7
6
)
8
7
@@ -36,11 +35,6 @@ const (
36
35
SpeechResponseFormatPcm SpeechResponseFormat = "pcm"
37
36
)
38
37
39
- var (
40
- ErrInvalidSpeechModel = errors .New ("invalid speech model" )
41
- ErrInvalidVoice = errors .New ("invalid voice" )
42
- )
43
-
44
38
type CreateSpeechRequest struct {
45
39
Model SpeechModel `json:"model"`
46
40
Input string `json:"input"`
@@ -49,32 +43,7 @@ type CreateSpeechRequest struct {
49
43
Speed float64 `json:"speed,omitempty"` // Optional, default to 1.0
50
44
}
51
45
52
- func contains [T comparable ](s []T , e T ) bool {
53
- for _ , v := range s {
54
- if v == e {
55
- return true
56
- }
57
- }
58
- return false
59
- }
60
-
61
- func isValidSpeechModel (model SpeechModel ) bool {
62
- return contains ([]SpeechModel {TTSModel1 , TTSModel1HD , TTSModelCanary }, model )
63
- }
64
-
65
- func isValidVoice (voice SpeechVoice ) bool {
66
- return contains ([]SpeechVoice {VoiceAlloy , VoiceEcho , VoiceFable , VoiceOnyx , VoiceNova , VoiceShimmer }, voice )
67
- }
68
-
69
46
func (c * Client ) CreateSpeech (ctx context.Context , request CreateSpeechRequest ) (response RawResponse , err error ) {
70
- if ! isValidSpeechModel (request .Model ) {
71
- err = ErrInvalidSpeechModel
72
- return
73
- }
74
- if ! isValidVoice (request .Voice ) {
75
- err = ErrInvalidVoice
76
- return
77
- }
78
47
req , err := c .newRequest (ctx , http .MethodPost , c .fullURL ("/audio/speech" , string (request .Model )),
79
48
withBody (request ),
80
49
withContentType ("application/json" ),
0 commit comments