百度语音识别shell脚本
function vopLogin(){ appKey="$1" secretKey="$2" url="https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id=$appKey&client_secret=$secretKey" token=`curl "$url" | awk '{ split($0,aa,"\"access_token\":\""); split(aa[2],bb,"\""); print bb[1]; }'` } function escapeResult(){ awk 'BEGIN{ OFS="\t" }{ split($0,aa,"\"result\":\\[\""); split(aa[2],bb,"\"]"); print "print u\""bb[1]"\"" }' | python } function vopRegnize(){ fmt="$1" fn="$2" ss=`curl -s -T $fn -H "Content-Type: audio/$fmt;rate=8000" "http://vop.baidu.com/server_api?lan=zh&cuid=123456&token=$token"` echo "$ss" | escapeResult }
测试
vopRegnize wav ./eee.wav 嗯嗯我不知道当时是怎么跟你说的哈这是我之前有告诉她了要帮你们推荐的时候我是很明确已经问我的问题我就没以为你是没有孩子的,那么我
Comments