@@ -104,10 +104,15 @@ func RelayAudioHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
104
104
}
105
105
106
106
fullRequestURL := util .GetFullRequestURL (baseURL , requestURL , channelType )
107
- if relayMode == constant .RelayModeAudioTranscription && channelType == common .ChannelTypeAzure {
108
- // https://learn.microsoft.com/en-us/azure/ai-services/openai/whisper-quickstart?tabs=command-line#rest-api
107
+ if channelType == common .ChannelTypeAzure {
109
108
apiVersion := util .GetAzureAPIVersion (c )
110
- fullRequestURL = fmt .Sprintf ("%s/openai/deployments/%s/audio/transcriptions?api-version=%s" , baseURL , audioModel , apiVersion )
109
+ if relayMode == constant .RelayModeAudioTranscription {
110
+ // https://learn.microsoft.com/en-us/azure/ai-services/openai/whisper-quickstart?tabs=command-line#rest-api
111
+ fullRequestURL = fmt .Sprintf ("%s/openai/deployments/%s/audio/transcriptions?api-version=%s" , baseURL , audioModel , apiVersion )
112
+ } else if relayMode == constant .RelayModeAudioSpeech {
113
+ // https://learn.microsoft.com/en-us/azure/ai-services/openai/text-to-speech-quickstart?tabs=command-line#rest-api
114
+ fullRequestURL = fmt .Sprintf ("%s/openai/deployments/%s/audio/speech?api-version=%s" , baseURL , audioModel , apiVersion )
115
+ }
111
116
}
112
117
113
118
requestBody := & bytes.Buffer {}
@@ -123,7 +128,7 @@ func RelayAudioHelper(c *gin.Context, relayMode int) *relaymodel.ErrorWithStatus
123
128
return openai .ErrorWrapper (err , "new_request_failed" , http .StatusInternalServerError )
124
129
}
125
130
126
- if relayMode == constant .RelayModeAudioTranscription && channelType == common .ChannelTypeAzure {
131
+ if ( relayMode == constant .RelayModeAudioTranscription || relayMode == constant . RelayModeAudioSpeech ) && channelType == common .ChannelTypeAzure {
127
132
// https://learn.microsoft.com/en-us/azure/ai-services/openai/whisper-quickstart?tabs=command-line#rest-api
128
133
apiKey := c .Request .Header .Get ("Authorization" )
129
134
apiKey = strings .TrimPrefix (apiKey , "Bearer " )
0 commit comments