Skip to content

Commit

Permalink
[pr2eus/speak.l, test/speak-test.l] Add speak-en-jp to switch languag…
Browse files Browse the repository at this point in the history
…e by speak_language rosparam and add test codes
  • Loading branch information
snozawa committed Nov 24, 2016
1 parent 8538422 commit f398382
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pr2eus/speak.l
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,21 @@
:wait wait
:timeout timeout))

(defun speak-en-jp
(en-str jp-str
&key google (wait *speak-wait*) (topic-name "robotsound") (timeout *speak-timeout*) (debug nil))
"Speak english or japanese.
Speak languages are switched by 'speak_language' rosparam.
If 'speak_language' is 'japanese' (neglect up/down cases), use speak-jp.
Otherwise, use speak-en."
(let ((lang (ros::get-param "speak_language")))
(cond
((and (stringp lang) (string= "JAPANESE" (string-upcase lang)))
(if debug (warn ";; Use Japanese~%"))
(speak-jp jp-str :google google :wait wait :topic-name topic-name :timeout timeout))
(t
(if debug (warn ";; Use English~%"))
(speak-en en-str :google google :wait wait :topic-name topic-name :timeout timeout))
)))

(provide :speak) ;; end of speak.l
11 changes: 11 additions & 0 deletions pr2eus/test/speak-test.l
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@
(deftest test-speak-google ()
(assert (speak-google "bonjour" :timeout 10 :lang :fr)))

(deftest test-speak-en-jp ()
(labels ((test-speak
()
(and (speak-en-jp "hello, world" "こんにちは" :timeout 10 :debug t)
;; (speak-en-jp "hello, world" "こんにちは" :wait t :debug t)
(speak-en-jp "hello, world" "こんにちは" :timeout 10 :google t :debug t))))
(assert (progn (test-speak)))
(assert (progn (ros::set-param "speak_language" "Japanese") (test-speak)))
(assert (progn (ros::set-param "speak_language" "English") (test-speak)))
))

(run-all-tests)
(exit)

0 comments on commit f398382

Please sign in to comment.