因为比赛原因,有幸申请到了一块香蕉派M2-Ultra,然后项目要用到语音识别,我们选择的是百度语音api,因为科大讯飞的LinuxSDK对Arm架构的很不友好。
刷入系统
我选择的是debian 8.6 with mate desktop
刷入过程几乎同上一篇博客
ssh登录
账号是pi
密码是bananapi
到百度语音官网创建应用
下载REST API的SDK
在Sample.java中填写三个KEY
用IDE编译java工程
将编译好的工程复制到香蕉派上
将test.pcm(语音文件)复制到Baidu_Voice_RestApi_SampleCode/sample/java/bin
安装jdk
jdk版本必须与编译工程的电脑的jdk版本一致,否则会出错
下载jdk
输入命令
jdk文件名为你下载的jdk文件名
sudo mkdir /opt/jdk/
sudo mv ~/jdk-8u66-linux-x64.tar.gz /opt/jdk/
sudo cd /opt/jdk/
sudo tar -zxf jdk-8u66-linux-x64.tar.gz
sudo update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_66/bin/java 100
sudo update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_66/bin/javac 100
配置java
sudo update-alternatives --config java
然后会提示
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 auto mode
* 1 /opt/jdk/jdk1.8.0_66/bin/java 100 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode
Press enter to keep the current choice[*], or type selection number: 1
输入我们刚刚下载的jdk的序号,此处为1
配置javac
sudo update-alternatives --config javac
然后会提示
There are 2 choices for the alternative javac (providing /usr/bin/javac).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1051 auto mode
* 1 /opt/jdk/jdk1.8.0_66/bin/javac 100 manual mode
2 /usr/lib/jvm/java-7-openjdk-amd64/bin/javac 1051 manual mode
Press enter to keep the current choice[*], or type selection number: 1
输入我们刚刚下载的jdk的序号,此处为1
检查java版本
java -version
若显示版本是我们下载的就表示配置成功
检查javac版本
javac -version
若显示版本是我们下载的就表示配置成功
运行Demo
去到/Baidu_Voice_RestApi_SampleCode/sample/java/bin目录
输入
java com.baidu.speech.serviceapi.Sample
若显示
{
"result": ["百度语音提供技术支持,"],
"err_msg": "success.",
"sn": "705505674701484467212",
"corpus_no": "6375738131747720730",
"err_no": 0
}
{
"result": ["百度语音提供技术支持,"],
"err_msg": "success.",
"sn": "54171429721484467213",
"corpus_no": "6375738136019367423",
"err_no": 0
}
则表示使用成功
网友评论