test_julius.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>
4 
5 
6 import rospy
7 import unittest
8 from speech_recognition_msgs.msg import SpeechRecognitionCandidates
9 
10 
11 class TestJulius(unittest.TestCase):
12 
13  def on_speech(self, msg):
14  self.transcripts.append(msg.transcript[0])
15 
16  def test_julius(self):
17  expected_sentences = ['わかめ', 'きつね']
18  self.transcripts = []
19  sub = rospy.Subscriber("speech_to_text", SpeechRecognitionCandidates,
20  self.on_speech)
21 
22  start_time = rospy.Time.now()
23  while len(self.transcripts) < len(expected_sentences):
24  rospy.sleep(1)
25  if (rospy.Time.now() - start_time).to_sec() > 20:
26  self.fail("Timeout.")
27 
28  for s in expected_sentences:
29  self.assertTrue(s in self.transcripts)
30 
31 
32 if __name__ == '__main__':
33  import rostest
34  rospy.init_node("test_julius")
35  rostest.rosrun("julius_ros", "test_julius", TestJulius)
def on_speech(self, msg)
Definition: test_julius.py:13


julius_ros
Author(s): Yuki Furuta
autogenerated on Wed Jul 10 2019 03:47:05