Skip to content

Instantly share code, notes, and snippets.

@hailiang-wang
Last active May 5, 2017 02:51
Show Gist options
  • Save hailiang-wang/a0b89756effc84cb6d8831a33bbac960 to your computer and use it in GitHub Desktop.
Save hailiang-wang/a0b89756effc84cb6d8831a33bbac960 to your computer and use it in GitHub Desktop.
xfyun api
#! /bin/bash
###########################################
# Test Wav file for xfyun api
# https://hub.docker.com/r/samurais/xfyun-api/
###########################################
# constants
baseDir=$(cd `dirname "$0"`;pwd)
hostUri=localhost
port=9666
filePath=$baseDir/../src/test/fixtures/test2.mp3
sampleRate=8000
# functions
function convert_mp3_to_wav(){
sox -t mp3 -r $sampleRate -c 1 $filePath -r 16000 -t wav $filePath.wav
}
# main
[ -z "${BASH_SOURCE[0]}" -o "${BASH_SOURCE[0]}" = "$0" ] || return
cd $baseDir
convert_mp3_to_wav $filePath
# Specify HTTP multipart POST data
curl -X POST \
-F "audiofile=@$filePath.wav" \
-F data="{\"lang\":\"zh_cn\", \"accent\": \"mandarin\", \"sample_rate\":16000}" \
http://$hostUri:$port/api/v1/stt/wav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment