docker run --name $containerName -d --env XFYUN_APP_ID=YOUR_ID -p 9666:8090 --restart always samurais/xfyun-api:latest
Get XFYUN_APP_ID from http://www.xfyun.cn/services/voicedictation with Linux 平台, 语音听写 服务.
Process a local wav file with shell and curl.
#! /bin/bash
# constants
baseDir=$(cd `dirname "$0"`;pwd)
hostUri=localhost
port=9666
filePath=$test/fixtures/test2.wav
sampleRate=8000
# main
cd $baseDir
curl -X POST \
# Specify HTTP multipart POST data
-F "audiofile=@$filePath" \
-F data="{\"lang\":\"zh_cn\", \"accent\": \"mandarin\", \"sample_rate\":$sampleRate}" \
http://$hostUri:$port/api/v1/stt/wav
Send the request with formdata, post wav file as audiofile, post lang, accent and sample_rate as data.
filePath 音频文件位置,绝对路径
data 识别参数
// 语言
// zh_cn:简体中文
// zh_tw:繁体中文
// en_us:英语
// 默认为zh_cn
lang: 'zh_cn',
// 口音
// mandarin:普通话
// cantonese:粤语
// 默认为mandarin
accent: 'mandarin',
// 音频格式
// 8000, 16000, 默认为16000
sample_rate: 16000
e.g.
sox -t mp3 -r $sampleRate -c 1 $filePath -r 16000 -t wav $filePath.wav
Content type
Image
Digest
Size
294.6 MB
Last updated
over 9 years ago
docker pull samurais/xfyun-api