0

I have code like below, but it outputs

Session Started (ID= 2e73d3d49f934b66af05ca3438339e81) 
Timed out

And it seems can not detect which language is in the audio file.

How can I resolve the timeout issue and detect language type ?

func sessionStartedHandler(event speech.SessionEventArgs) {
    defer event.Close()
    fmt.Println("Session Started (ID=", event.SessionID, ")")
}
// handlers ignored
func main() {
    speechKey := os.Getenv("SPEECH_KEY")
    speechRegion := os.Getenv("SPEECH_REGION")

    file := "./OSR_us_000_0010_8k.wav"

    audioConfig, err := audio.NewAudioConfigFromWavFileInput(file)

    defer audioConfig.Close()

    config, err := speech.NewSpeechConfigFromSubscription(speechKey, speechRegion)
    defer config.Close()

    speechRecognizer, err := speech.NewSpeechRecognizerFromConfig(config, audioConfig)
    defer speechRecognizer.Close()

    speechRecognizer.SessionStarted(sessionStartedHandler)

    task := speechRecognizer.RecognizeOnceAsync()
    var outcome speech.SpeechRecognitionOutcome
    select {
    case outcome = <-task:
        fmt.Println("got", outcome)
    case <-time.After(10 * time.Second):
        fmt.Println("Timed out")
        return
    }
    defer outcome.Close()
    if outcome.Error != nil {
        fmt.Println("Got an error: ", outcome.Error)
    }
    fmt.Println("Got a recognition!")
}

djy
  • 737
  • 6
  • 14

1 Answers1

0

Please see the Language Identification document here: https://learn.microsoft.com/azure/cognitive-services/speech-service/language-identification . But note that we do not yet support Language Identification in the GO programing language. You will have to use one of the other supported programming languages.

If you are not able to make it work even with the examples given there, feel free to open a GitHub issue in the Speech SDK samples repo and we will help you. https://github.com/Azure-Samples/cognitive-services-speech-sdk/issues

Darren Cohen
  • 126
  • 6