LoginSignup
17
18

More than 5 years have passed since last update.

ROSを使ってWebインターフェース経由で音声認識する

Last updated at Posted at 2015-12-15

実は結構前から作っていましたが、後輩などいろいろな人に使い方を質問されるのでここに書いておくことにしました。

すること

  • 音声認識をブラウザから行う
  • ROSのメッセージとして文字データをpublishする
  • 結果を見てみる

前提

  • ROSが入ったPC
  • マイクデバイス
  • Google Chromeが入ったPC or Tablet

インストール

https://github.com/tork-a/visualization_rwt
に従う。

  • まず依存パッケージをインストール
sudo apt-get install python-rosdep python-catkin-tools
cd /path/to/catkin_ws
wstool set --git rwt_ros https://github.com/tork-a/rwt_ros.git -t src
wstool set --git visualization_rwt https://github.com/tork-a/visualization_rwt.git
wstool up -t src rwt_ros visualization_rwt
rosdep install --from-paths src --ignore-src -r -n -y
  • パッケージをインストール

拙作 rwt_speech_recognition を使います

catkin build rwt_speech_recognition
source devel/setup.bash
  • 起動する
roslaunch rwt_speech_recognition rwt_speech_recognition.launch

これでChromeの入ったPCかTablet(Androidですね)で起動したサービスのページにアクセス
NOTE FirefoxやSafariは音声認識に対応していないので使えません。・・・え?いんたーねっとえくすぷろーら?

http://<your host name>:8000/rwt_speech_recognition/
NOTE 最後の/は重要です。

roslaunchしたPCでブラウザを立ち上げた場合は

ですね。

Screenshot_from_2015-12-15 14:39:03.png

あとはしゃべるだけです。

  • 認識結果

音声認識の結果はページ中の窓に書かれたトピックに随時パブリッシュされます。
写真では/Tablet/voiceになっています。

Screenshot_from_2015-12-15 15:34:33.png

$ rostopic echo /Tablet/voice
transcript: ['\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf', '\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x82\x8f', '\xe3\x82\xb3\xe3\x83\xb3\xe3\x83\x8b\xe3\x83\x81\xe3\x83\xaf', '\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x82\x8e']
confidence: [0.9532432556152344, 0.0, 0.0, 0.0]

見ての通り日本語はエンコードされていてHuman Readableではありません。が、ちゃんと送ることができています。

適当なプログラムを書いて確認して見ました。

;; test.l
;; Author: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>

(ros::load-ros-manifest "speech_recognition_msgs")

(ros::roseus "test_node")

(ros::subscribe "/Tablet/voice"
                speech_recognition_msgs::SpeechRecognitionCandidates
                #'(lambda (msg)
                    (warn "received: ~A~%" (send msg :transcript))))
(ros::spin)
(exit)
rosrun roseus roseus test.l
configuring by "/home/furushchev/ros/hydro_parent/devel/share/euslisp/jskeus/eus//lib/eusrt.l"
;; readmacro ;; object ;; packsym ;; common ;; constants ;; stream ;; string ;; loader ;; pprint ;; process ;; hashtab ;; array ;; mathtran ;; eusdebug ;; eusforeign ;; coordinates ;; tty ;; history ;; toplevel ;; trans ;; comp ;; builtins ;; par ;; intersection ;; geoclasses ;; geopack ;; geobody ;; primt ;; compose ;; polygon ;; viewing ;; viewport ;; viewsurface ;; hid ;; shadow ;; bodyrel ;; dda ;; helpsub ;; eushelp ;; xforeign ;; Xdecl ;; Xgraphics ;; Xcolor ;; Xeus ;; Xevent ;; Xpanel ;; Xitem ;; Xtext ;; Xmenu ;; Xscroll ;; Xcanvas ;; Xtop ;; Xapplwin 
connected to Xserver DISPLAY=:0.0
X events are being asynchronously monitored.
;; pixword ;; RGBHLS ;; convolve ;; piximage ;; pbmfile ;; image_correlation ;; oglforeign ;; gldecl ;; glconst ;; glforeign ;; gluconst ;; gluforeign ;; glxconst ;; glxforeign ;; eglforeign ;; eglfunc ;; glutil ;; gltexture ;; glprim ;; gleus ;; glview ;; toiv-undefined ;; fstringdouble irtmath irtutil irtc irtgeoc irtgraph pgsql 
;; extending gcstack 0x597b950[16374] --> 0x5c7f570[32748] top=395f
irtgeo euspqp pqp irtscene irtmodel irtdyna irtrobot irtsensor irtbvh irtcollada irtpointcloud irtx eusjpeg euspng png irtimage irtglrgb irtgl irtviewer 
EusLisp 9.15(1989ebd 1.0.10) for Linux64 created on leus-MacBookPro(Sat Oct 31 18:20:32 JST 2015)
roseus ;; loading roseus("ee7e7ac") on euslisp((9.15 leus-MacBookPro Sat Oct 31 18:20:32 JST 2015 1989ebd 1.0.10))
eustf roseus_c_util
received: (こんにちは こんにちわ コンニチワ こんにちゎ)

NOTE じつは日本語などのNon ASCII文字も見られるようにして見ましたが、あえなく撃沈しました。
ref: https://github.com/ros/genpy/pull/34

17
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
18