From 7ac3a852f42083f1c2d3c07750bc4ab9e3583306 Mon Sep 17 00:00:00 2001 From: Martial BE Date: Wed, 13 Mar 2024 14:41:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20fix=20Azure=20Speech=20vo?= =?UTF-8?q?ice=20mapping=20issue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- providers/azureSpeech/speech.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/providers/azureSpeech/speech.go b/providers/azureSpeech/speech.go index bf7f11f5..9d03dbed 100644 --- a/providers/azureSpeech/speech.go +++ b/providers/azureSpeech/speech.go @@ -32,7 +32,7 @@ func CreateSSML(text string, name string, role string) string { } func (p *AzureSpeechProvider) GetVoiceMap() map[string][]string { - voiceMap := map[string][]string{ + defaultVoiceMapping := map[string][]string{ "alloy": {"zh-CN-YunxiNeural"}, "echo": {"zh-CN-YunyangNeural"}, "fable": {"zh-CN-YunxiNeural", "Boy"}, @@ -42,27 +42,27 @@ func (p *AzureSpeechProvider) GetVoiceMap() map[string][]string { } 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 { - return voiceMap + return defaultVoiceMapping } - for k, v := range customizeMap { - if _, ok := voiceMap[k]; !ok { + for key, value := range customVoiceMapping { + if _, exists := defaultVoiceMapping[key]; !exists { continue } - customizeValue, ok := v.(string) - if !ok { + customVoiceValue, isString := value.(string) + if !isString || customVoiceValue == "" { continue } - customizeVoice := strings.Split(customizeValue, "|") - voiceMap[k] = customizeVoice + customizeVoice := strings.Split(customVoiceValue, "|") + defaultVoiceMapping[key] = customizeVoice } - return voiceMap + return defaultVoiceMapping } func (p *AzureSpeechProvider) getRequestBody(request *types.SpeechAudioRequest) *bytes.Buffer {