408 Request timed out Microsoft Speech to Text

后端 未结 2 723
执念已碎
执念已碎 2021-01-21 00:40

My .wav file length is just 4 seconds. Even after multiple retries and running it on cloud i am constantly getting following error

  * upload completely sent off         


        
相关标签:
2条回答
  • 2021-01-21 01:08

    I also ran into a few problems getting it to work. The following BASH script "bingrec.sh" may help make it more clear; enter your SUBSCRIPTION_KEY & adjust SAMPLERATE etc. as required. As others have pointed out, locale & scenarios need to be set to supported values, and instance_id and request_id need to be in GUID format. The audio file should be less than 10 seconds long, and have a sampling rate of 8000 or 16000. Also the curl "--data-binary" parameter requires an "@" in front of the audio filename.

    #!/bin/bash
    #  Usage:  ./bingrec.sh  /path/to/file 
    #  Send audio file $1 through Bing speech recognition API.
    #
    SUBSCRIPTION_KEY=<your-key-here>
    LOCALE=en-US
    SCENARIOS=ulm
    SAMPLERATE=8000
    CODEC=audio/pcm
    
    TARGET_FILE=$1
    if [ ! -f "$TARGET_FILE" ]; then
      echo Error:  file $TARGET_FILE does not exist!
      exit 1
    fi
    
    INSTANCE_ID=`uuidgen`    # random GUID for instance
    REQUEST_ID=`uuidgen`     # random GUID for request
    APPID=D4D52672-91D7-4C74-8AD8-42B1D98141A5   # APPID for Bing Speechrec API, don't change
    DEVICE_OS=linux          # arbitraty
    FORMAT=json
    
    AUTH_TOKEN=`curl -v -X POST "https://api.cognitive.microsoft.com/sts/v1.0/issueToken" -H "Content-type: application/x-www-form-urlencoded" -H "Content-Length: 0" -H "Ocp-Apim-Subscription-Key: ${SUBSCRIPTION_KEY}"`
    
    curl -v -X POST "https://speech.platform.bing.com/recognize?scenarios=${SCENARIOS}&appid=${APPID}&locale=${LOCALE}&device.os=${DEVICE_OS}&version=3.0&format=${FORMAT}&instanceid=${INSTANCE_ID}&requestid=${REQUEST_ID}" -H "Authorization: Bearer ${AUTH_TOKEN}" -H "Content-type: audio/wav; codec='${CODEC}'; samplerate=${SAMPLERATE}" --data-binary @${TARGET_FILE}
    
    0 讨论(0)
  • 2021-01-21 01:09

    I got this working. There were couple of issues. One was with the locale, which i changed to en-IN. and then scenarios=ulm. This seems to have done the trick. I was able to detect speech very clearly.

    0 讨论(0)
提交回复
热议问题