<s> import os <EOL> import timeit <EOL> import rospkg <EOL> from os . path import join <EOL> __path__ = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> from RappCloud import RappCloud <EOL> class RappInterfaceTest : <EOL> def __init__ ( self ) : <EOL> self . rappCloud = RappCloud ( ) <EOL> rospack = rospkg . RosPack ( ) <EOL> pkgDir = rospack . get_path ( '<STR_LIT>' ) <EOL> self . file_uri = join ( pkgDir , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . language = '<STR_LIT>' <EOL> self . audio_source = '<STR_LIT>' <EOL> self . words = [ u'<STR_LIT>' , u'<STR_LIT>' ] <EOL> self . sentences = self . words <EOL> self . grammar = [ ] <EOL> self . user = '<STR_LIT>' <EOL> self . valid_words_found = [ u'<STR_LIT>' ] <EOL> def execute ( self ) : <EOL> start_time = timeit . default_timer ( ) <EOL> response = self . rappCloud . speech_detection_sphinx4 ( self . language , self . audio_source , self . words , self . sentences , self . grammar , self . file_uri , self . user ) <EOL> end_time = timeit . default_timer ( ) <EOL> self . elapsed_time = end_time - start_time <EOL> return self . validate ( response ) <EOL> def validate ( self , response ) : <EOL> error = response [ '<STR_LIT:error>' ] <EOL> if error != "<STR_LIT>" : <EOL> return [ error , self . elapsed_time ] <EOL> return_data = response [ '<STR_LIT>' ] <EOL> if self . valid_words_found == return_data : <EOL> return [ True , self . elapsed_time ] <EOL> else : <EOL> return [ "<STR_LIT>" + str ( return_data ) , self . elapsed_time ] </s>
