microsoft / cognitive-services-speech-sdk-go

Go bindings for the Microsoft Cognitive Services Speech SDK
MIT License
88 stars 32 forks source link

Error report during request, after successful SDK installation&build on CentOS. #124

Open aetherwu opened 7 months ago

aetherwu commented 7 months ago

Config as https://learn.microsoft.com/en-us/azure/ai-services/speech-service/quickstarts/setup-platform?tabs=windows%2Crhel-centos%2Cdotnetcli%2Cdotnet%2Cjre%2Cmaven%2Cbrowser%2Cmac%2Cpypi&pivots=programming-language-go

Go build works fine. Go run Go-Gin works fine. Same code runs normally on MacOS.

However error reports at:

speechConfig, err := speech.NewSpeechConfigFromSubscription(speechKey, speechRegion)

07:45:15 app | SIGSEGV: segmentation violation 07:45:15 app | PC=0x23d0 m=0 sigcode=1 addr=0x23d0 07:45:15 app | signal arrived during cgo execution 07:45:15 app | 07:45:15 app | goroutine 16 gp=0xc00042b500 m=0 mp=0x1565be0 [syscall]: 07:45:15 app | runtime.cgocall(0xad515e, 0xc000054d58) 07:45:15 app | /usr/local/go/src/runtime/cgocall.go:157 +0x4b fp=0xc000054d30 sp=0xc000054cf8 pc=0x41716b 07:45:15 app | github.com/Microsoft/cognitive-services-speech-sdk-go/speech._Cfunc_speech_config_from_subscription(0xc000042790, 0x1d92ea0, 0x1d93f90) 07:45:15 app | _cgo_gotypes.go:1257 +0x4c fp=0xc000054d58 sp=0xc000054d30 pc=0x9c38ec 07:45:15 app | github.com/Microsoft/cognitive-services-speech-sdk-go/speech.NewSpeechConfigFromSubscription.func3(0xc000042790, 0x1d92ea0, 0x1d93f90) 07:45:15 app | /root/go/pkg/mod/github.com/!microsoft/cognitive-services-speech-sdk-go@v1.33.0/speech/speech_config.go:54 +0x5f fp=0xc000054d88 sp=0xc000054d58 pc=0x9c813f 07:45:15 app | github.com/Microsoft/cognitive-services-speech-sdk-go/speech.NewSpeechConfigFromSubscription({0xc00002c00e, 0x20}, {0xd147e1, 0x6}) 07:45:15 app | /root/go/pkg/mod/github.com/!microsoft/cognitive-services-speech-sdk-go@v1.33.0/speech/speech_config.go:54 +0x105 fp=0xc000054e28 sp=0xc000054d88 pc=0x9c7fa5

No formal error reported.

Enviroment: CentOS 7 3.10.0-1160.95.1.el7.x86_64

NAME="CentOS Linux" VERSION="7 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="7" PRETTY_NAME="CentOS Linux 7 (Core)" ANSI_COLOR="0;31"

aetherwu commented 7 months ago

After I've read all doc I found something hidden in note:

"The Linux .tar package contains specific libraries for RHEL/CentOS 7. These are in lib/centos7-x64 as shown in the environment setting example for LD_LIBRARY_PATH above. Speech SDK libraries in lib/x64 are for all the other supported Linux x64 distributions (including RHEL/CentOS 8) and don't work on RHEL/CentOS 7."

Let me translate it for people who need extra help like me:

vim ~/.bashrc

export SPEECHSDK_ROOT="/root/speechsdk"
export CGO_CFLAGS="-I$SPEECHSDK_ROOT/include/c_api"
export CGO_LDFLAGS="-L$SPEECHSDK_ROOT/lib/centos7-x64 -lMicrosoft.CognitiveServices.Speech.core"
export LD_LIBRARY_PATH="$SPEECHSDK_ROOT/lib/centos7-x64:$LD_LIBRARY_PATH"

source ~/.bashrc

To replace similar instructions in offical doc.

aetherwu commented 7 months ago

However, I couldn't make it work.

In my case,

if outcome.Result.Reason == common.SynthesizingAudioCompleted {
        fmt.Printf("Speech synthesized: [%s].\n", text)
    } 

was called, but

speechSynthesizer.SynthesisCompleted(func(event speech.SpeechSynthesisEventArgs) {
    fmt.Printf("SynthesisCompleted")
    defer event.Close()
})

was not.

ralph-msft commented 7 months ago

Please include the SDK logs files: https://learn.microsoft.com/en-us/azure/ai-services/speech-service/how-to-use-logging