1. 程式人生 > >ROS kinetic語音識別(轉)

ROS kinetic語音識別(轉)

line 目錄 路徑 inf AC ESS data html amd

1.安裝依賴

1.1安裝ros-kinetic-audio-common

1 sudo apt-get install ros-kinetic-audio-common

1.2 安裝libasound2

sudo apt-get install libasound2

1.3 安裝libgstreamer0.10

sudo apt-get install gstreamer0.10-*

1.4安裝python-gst0.10

sudo apt-get install python-gst0.10

2.安裝 libsphinxbase1

下載地址:https://packages.debian.org/jessie/libsphinxbase1

sudo dpkg -i libsphinxbase1_0.8-6_amd64.deb

3. 安裝libpocketsphinx1

下載地址:https://packages.debian.org/jessie/libpocketsphinx1

sudo dpkg -i libpocketsphinx1_0.8-5_amd64.deb 

4.安裝gstreamer0.10-pocketsphinx

下載地址:https://packages.debian.org/jessie/gstreamer0.10-pocketsphinx

sudo dpkg -i gstreamer0.10-pocketsphinx_0.8-5_amd64.deb

5.安裝pocketsphinx

5.1進入工作空間,git源碼

cd ~/dev/catkin_ws/src
git clone https://github.com/mikeferguson/pocketsphinx

5.2下載英文語音包pocketsphinx-hmm-en-tidigits (0.8-5)

下載的網站:https://packages.debian.org/jessie/pocketsphinx-hmm-en-tidigits

sudo dpkg -i pocketsphinx-hmm-en-tidigits_0.8-5_all.deb

會加壓安裝到/usr/share/目錄如下所示

技術分享圖片
/usr/share/doc/pocketsphinx-hmm-en-tidigits/changelog.Debian.gz
/usr/share/doc/pocketsphinx-hmm-en-tidigits/changelog.gz
/usr/share/doc/pocketsphinx-hmm-en-tidigits/copyright
/usr/share/pocketsphinx/model/hmm/en/tidigits/feat.params
/usr/share/pocketsphinx/model/hmm/en/tidigits/mdef
/usr/share/pocketsphinx/model/hmm/en/tidigits/means
/usr/share/pocketsphinx/model/hmm/en/tidigits/sendump
/usr/share/pocketsphinx/model/hmm/en/tidigits/transition_matrices
/usr/share/pocketsphinx/model/hmm/en/tidigits/variances
/usr/share/pocketsphinx/model/lm/en/tidigits.DMP
/usr/share/pocketsphinx/model/lm/en/tidigits.dic
/usr/share/pocketsphinx/model/lm/en/tidigits.fsg
技術分享圖片

在包pocketsphinx下面建一個model目錄,存放語音模型文件

cd ~/dev/catkin_ws/src/pocketsphinx
mkdir model

將下載好的語音文件,解壓後,將其中的model文件下的所有文件拷貝到~/dev/catkin_ws/src/pocketsphinx/model下,也可以不復制。

6 啟動pocketsphinx測試

直接運行pocketsphinx啟動腳本命令“roslaunch pocketsphinx robocup.launch”會出現如下錯誤,

技術分享圖片

為此,首先我對recognizer.py的做了如下修改:

1)註釋掉self.asr.set_property(‘configured‘, True)

2)添加lm,dict,hmm支持英語識別(如果是其他語言(如普通話)可以改為別的路徑)

self.asr.set_property(‘lm‘, ‘/usr/share/pocketsphinx/model/lm/en/tidigits.DMP‘)
self.asr.set_property(‘dict‘, ‘/usr/share/pocketsphinx/model/lm/en/tidigits.dic‘)
self.asr.set_property(‘hmm‘, ‘/usr/share/pocketsphinx/model/hmm/en/tidigits‘)

技術分享圖片

這些安裝好之後,可以開始測試pocketsphinx的語音識別功能了:

1.終端運行launch啟動文件:

roslaunch pocketsphinx robocup.launch

2.嘗試說一些簡單的語句,(如果使用英文庫,說一些數字;如果使用普通話庫講中文),查看識別結果

3.用rostopic echo進行查看識別的輸出,即ROS發布的結果消息)

rostopic echo /recognizer/output

7.也可以下載其他包進行測試

中文普通話

pocketsphinx-hmm-zh-tdt https://packages.debian.org/jessie/pocketsphinx-hmm-zh-tdt

pocketsphinx-lm-zh-hans-gigatdt https://packages.debian.org/jessie/pocketsphinx-lm-zh-hans-gigatdt

後期考慮在launch文件中設置參數,在recognizer.py加載參數的讀取

參考:http://blog.csdn.net/x_r_su/article/details/53022746?locationNum=1&fps=1

http://www.ncnynl.com/archives/201701/1220.html

ROS kinetic語音識別(轉)