🐛 fix: fix Azure Speech voice mapping issue
This commit is contained in:
parent
3d60f94a74
commit
7ac3a852f4
@ -32,7 +32,7 @@ func CreateSSML(text string, name string, role string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *AzureSpeechProvider) GetVoiceMap() map[string][]string {
|
func (p *AzureSpeechProvider) GetVoiceMap() map[string][]string {
|
||||||
voiceMap := map[string][]string{
|
defaultVoiceMapping := map[string][]string{
|
||||||
"alloy": {"zh-CN-YunxiNeural"},
|
"alloy": {"zh-CN-YunxiNeural"},
|
||||||
"echo": {"zh-CN-YunyangNeural"},
|
"echo": {"zh-CN-YunyangNeural"},
|
||||||
"fable": {"zh-CN-YunxiNeural", "Boy"},
|
"fable": {"zh-CN-YunxiNeural", "Boy"},
|
||||||
@ -42,27 +42,27 @@ func (p *AzureSpeechProvider) GetVoiceMap() map[string][]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if p.Channel.Plugin == nil {
|
if p.Channel.Plugin == nil {
|
||||||
return voiceMap
|
return defaultVoiceMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
customizeMap, ok := p.Channel.Plugin.Data()["voice"]
|
customVoiceMapping, ok := p.Channel.Plugin.Data()["voice"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return voiceMap
|
return defaultVoiceMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range customizeMap {
|
for key, value := range customVoiceMapping {
|
||||||
if _, ok := voiceMap[k]; !ok {
|
if _, exists := defaultVoiceMapping[key]; !exists {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
customizeValue, ok := v.(string)
|
customVoiceValue, isString := value.(string)
|
||||||
if !ok {
|
if !isString || customVoiceValue == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
customizeVoice := strings.Split(customizeValue, "|")
|
customizeVoice := strings.Split(customVoiceValue, "|")
|
||||||
voiceMap[k] = customizeVoice
|
defaultVoiceMapping[key] = customizeVoice
|
||||||
}
|
}
|
||||||
|
|
||||||
return voiceMap
|
return defaultVoiceMapping
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *AzureSpeechProvider) getRequestBody(request *types.SpeechAudioRequest) *bytes.Buffer {
|
func (p *AzureSpeechProvider) getRequestBody(request *types.SpeechAudioRequest) *bytes.Buffer {
|
||||||
|
Loading…
Reference in New Issue
Block a user