test_julius.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 # Copyright: Yuki Furuta <furushchev@jsk.imi.i.u-tokyo.ac.jp>
00004 
00005 
00006 import rospy
00007 import unittest
00008 from speech_recognition_msgs.msg import SpeechRecognitionCandidates
00009 
00010 
00011 class TestJulius(unittest.TestCase):
00012 
00013     def on_speech(self, msg):
00014         self.transcripts.append(msg.transcript[0])
00015 
00016     def test_julius(self):
00017         expected_sentences = ['わかめ', 'きつね']
00018         self.transcripts = []
00019         sub = rospy.Subscriber("speech_to_text", SpeechRecognitionCandidates,
00020                                self.on_speech)
00021 
00022         start_time = rospy.Time.now()
00023         while len(self.transcripts) < len(expected_sentences):
00024             rospy.sleep(1)
00025             if (rospy.Time.now() - start_time).to_sec() > 20:
00026                 self.fail("Timeout.")
00027 
00028         for s in expected_sentences:
00029             self.assertTrue(s in self.transcripts)
00030 
00031 
00032 if __name__ == '__main__':
00033     import rostest
00034     rospy.init_node("test_julius")
00035     rostest.rosrun("julius_ros", "test_julius", TestJulius)


julius_ros
Author(s): Yuki Furuta
autogenerated on Sat Sep 9 2017 02:33:31