Speech GO SDK don't support Continues Detect Language. Base on SDK 1.44.0
If I speak English first then speak Chinese in my test, GO SDK will recognize it as English at all.
Base on Issues' research, I can you can add two line hard code to fixed it.
**const SpeechServiceConnectionLanguageIdMode common.PropertyID = 3205**
speechConfig.SetProperty(SpeechServiceConnectionLanguageIdMode, "Continuous")
Can you help fixed it? and make GO SDK directly support SpeechServiceConnectionLanguageIdMode as "Continuous".
It's only missing a PropertyID setting.
No PropertyID setting screenshot:
With PropertyID setting screenshot:
Sample Code as below:
package main
import (
"bufio"
"fmt"
"log"
"os"
"time"
"github.com/Microsoft/cognitive-services-speech-sdk-go/audio"
"github.com/Microsoft/cognitive-services-speech-sdk-go/common"
"github.com/Microsoft/cognitive-services-speech-sdk-go/speech"
)
func continuousLanguageDetection() {
speechKey := os.Getenv("ASIA_SPEECH_KEY")
speechRegion := os.Getenv("ASIA_SPEECH_REGION")
if speechKey == "" || speechRegion == "" {
log.Fatal("错误: 请设置 ASIA_SPEECH_KEY 和 ASIA_SPEECH_REGION 环境变量。")
}
speechConfig, err := speech.NewSpeechConfigFromSubscription(speechKey, speechRegion)
if err != nil {
log.Fatalf("创建语音配置失败: %v", err)
}
defer speechConfig.Close()
speechConfig.SetOutputFormat(common.Detailed)
const SpeechServiceConnectionLanguageIdMode common.PropertyID = 3205
speechConfig.SetProperty(SpeechServiceConnectionLanguageIdMode, "Continuous")
candidateLanguages := []string{"zh-CN", "en-US"}
autoDetectConfig, err := speech.NewAutoDetectSourceLanguageConfigFromLanguages(candidateLanguages)
if err != nil {
log.Fatalf("创建自动语言检测配置失败: %v", err)
}
defer autoDetectConfig.Close()
var audioConfig *audio.AudioConfig
if len(os.Args) > 1 {
audioConfig, err = audio.NewAudioConfigFromWavFileInput(os.Args[1])
if err != nil {
log.Fatalf("创建音频文件配置失败: %s", err)
}
} else {
audioConfig, err = audio.NewAudioConfigFromDefaultMicrophoneInput()
if err != nil {
log.Fatalf("创建麦克风配置失败: %v", err)
}
}
defer audioConfig.Close()
speechRecognizer, err := speech.NewSpeechRecognizerFomAutoDetectSourceLangConfig(speechConfig, autoDetectConfig, audioConfig)
if err != nil {
log.Fatalf("创建语音识别器失败: %v", err)
}
defer speechRecognizer.Close()
speechRecognizer.Recognized(func(event speech.SpeechRecognitionEventArgs) {
defer event.Close()
if event.Result.Reason == common.RecognizedSpeech {
fmt.Printf("✅ [%s] %s\n",
time.Now().Format("15:04:05"), event.Result.Text)
}
})
err = <-speechRecognizer.StartContinuousRecognitionAsync()
if err != nil {
log.Fatalf("启动持续识别失败: %v", err)
}
fmt.Println("识别已启动,按 Enter 键停止...")
bufio.NewReader(os.Stdin).ReadBytes('\n')
err = <-speechRecognizer.StopContinuousRecognitionAsync()
if err != nil {
log.Printf("停止识别时出错: %v", err)
}
}
func main() {
continuousLanguageDetection()
}
Speech GO SDK don't support Continues Detect Language. Base on SDK 1.44.0
If I speak English first then speak Chinese in my test, GO SDK will recognize it as English at all.
Base on Issues' research, I can you can add two line hard code to fixed it.
Can you help fixed it? and make GO SDK directly support SpeechServiceConnectionLanguageIdMode as "Continuous".
It's only missing a PropertyID setting.
No PropertyID setting screenshot:
With PropertyID setting screenshot:
Sample Code as below: