因?yàn)楸荣愒蚨魑玻行疑暾埖搅艘粔K香蕉派M2-Ultra幌墓,然后項(xiàng)目要用到語音識別句柠,我們選擇的是百度語音api,因?yàn)榭拼笥嶏w的LinuxSDK對Arm架構(gòu)的很不友好桃序。
刷入系統(tǒng)
我選擇的是debian 8.6 with mate desktop
刷入過程幾乎同上一篇博客
ssh登錄
賬號是pi
密碼是bananapi
到百度語音官網(wǎng)創(chuàng)建應(yīng)用
下載REST API的SDK
在Sample.java中填寫三個(gè)KEY
用IDE編譯java工程
將編譯好的工程復(fù)制到香蕉派上
將test.pcm(語音文件)復(fù)制到Baidu_Voice_RestApi_SampleCode/sample/java/bin
安裝jdk
jdk版本必須與編譯工程的電腦的jdk版本一致杖虾,否則會出錯(cuò)
下載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
若顯示版本是我們下載的就表示配置成功
運(yùn)行Demo
去到/Baidu_Voice_RestApi_SampleCode/sample/java/bin目錄
輸入
java com.baidu.speech.serviceapi.Sample
若顯示
{
"result": ["百度語音提供技術(shù)支持奇适,"],
"err_msg": "success.",
"sn": "705505674701484467212",
"corpus_no": "6375738131747720730",
"err_no": 0
}
{
"result": ["百度語音提供技術(shù)支持,"],
"err_msg": "success.",
"sn": "54171429721484467213",
"corpus_no": "6375738136019367423",
"err_no": 0
}
則表示使用成功