本文整理汇总了Python中RappCloud.RappCloud类的典型用法代码示例。如果您正苦于以下问题:Python RappCloud类的具体用法?Python RappCloud怎么用?Python RappCloud使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RappCloud类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
self.language = 'el'
self.text = u'Καλησπέρα. Είμαι ο ναο.'
self.destDir = '/tmp/'
# Set the valid results
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.text_to_speech(self.text, self.language, '')
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
if response['error']:
return [response['error'], self.elapsed_time]
# Get the returned data
audioData = response['audioData']
# Check if the returned data are equal to the expected
if len(audioData) > 0:
with open(self.destDir + response['basename'], 'wb') as f1:
f1.write(audioData)
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + 'Invalid size of audio data', self.elapsed_time]
示例2: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path('rapp_testing_tools')
self.file_uri = join(pkgDir, 'test_data',
'face_samples', 'multi_faces_frames', 'two_faces.jpg')
self.valid_numFaces = 2
def execute(self):
start_time = timeit.default_timer()
response = self.rappCloud.face_detection(self.file_uri)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
numFaces = len(response['faces'])
if self.valid_numFaces == numFaces:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + ' Number of faces found -> ' +\
str(numFaces) + ', expected -> ' + str(self.valid_numFaces), \
self.elapsed_time]
示例3: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
self.ontology_class = "Oven"
# Set the valid results
self.valid_results = [
'http://knowrob.org/kb/knowrob.owl#MicrowaveOven', \
'http://knowrob.org/kb/knowrob.owl#RegularOven', \
'http://knowrob.org/kb/knowrob.owl#ToasterOven', \
]
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.ontology_subclasses_of(self.ontology_class)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
# Get the returned data
return_data = response['results']
# Check if the returned data are equal to the expected
if self.valid_results == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]
示例4: __init__
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path("rapp_testing_tools")
self.file_uri = join(pkgDir, "test_data", "qr_samples", "easyMediumQr.jpg")
self.valid_results = {"qr_centers": [{"y": 498, "x": 632}], "qr_messages": ["Hello there"], "error": ""}
示例5: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
self.username = "rapp"
self.testType = "ReasoningCts"
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.cognitive_test_chooser(self.username, self.testType)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response["error"]
if error != "":
return [error, self.elapsed_time]
# Get the returned data
test_instance = response["test_instance"]
test_type = response["test_type"]
test_sub_type = response["test_subtype"]
questions = response["questions"]
possib_ans = response["possib_ans"]
correct_ans = response["correct_ans"]
# Check if the returned data are equal to the expected
if test_instance and test_type and test_sub_type and questions and possib_ans and correct_ans:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(response), self.elapsed_time]
示例6: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
self.username = "rapp"
self.test = "ReasoningCts_GJNNLYhq"
self.score = 50
# Set the valid results
self.valid_result_partial = "CognitiveTestPerformed"
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.record_cognitive_test_performance(self.username,
self.test, self.score)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
# Check if the returned data are equal to the expected
if self.valid_result_partial in response['performance_entry']:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(response), self.elapsed_time]
示例7: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path('rapp_testing_tools')
self.file_uri = join(pkgDir, 'test_data',
'qr_samples', 'mediumFarQr.jpg')
self.valid_results = {
'qr_centers': [{'y': 585, 'x': 690}],
'qr_messages': ['This is NAO from Greece'],
'error': ''
}
def execute(self):
start_time = timeit.default_timer()
response = self.rappCloud.qr_detection(self.file_uri)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
return_data = response
if self.valid_results == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]
示例8: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path('rapp_testing_tools')
self.file_uri = join(pkgDir, 'test_data',
'qr_samples', 'hardMediumQr.jpg')
self.valid_results = {
'qr_centers': [{'y': 543, 'x': 661}],
'qr_messages': ['This QR will be used to check the algorithmic robustness as it is quite small'],
'error': ''
}
def execute(self):
start_time = timeit.default_timer()
response = self.rappCloud.qr_detection(self.file_uri)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
return_data = response
if self.valid_results == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]
示例9: __init__
def __init__(self):
self.rappCloud = RappCloud()
self.username = "rapp"
self.test = "AwarenessCts_kRmyDqqu"
self.score = 50
# Set the valid results
self.valid_result_partial = "CognitiveTestPerformed"
示例10: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path('rapp_testing_tools')
self.file_uri = join(pkgDir, 'test_data',
'face_samples', 'etsardou_medium_angle.jpg')
self.valid_faces = [{
'up_left_point': {'y': 266.0, 'x': 746.0},
'down_right_point': {'y': 412.0, 'x': 892.0}
}]
def execute(self):
start_time = timeit.default_timer()
response = self.rappCloud.face_detection(self.file_uri)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
faces = response['faces']
if self.valid_faces == faces:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(response), self.elapsed_time]
示例11: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
self.parent_class_ = "SpatialThing"
self.child_class_ = "Oven"
self.recursive_ = True
# Set the valid results
self.valid_results = True;
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.ontology_is_subsuperclass_of(self.parent_class_, \
self.child_class_, self.recursive_)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
# Get the returned data
return_data = response['result']
# Check if the returned data are equal to the expected
if self.valid_results == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]
示例12: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path("rapp_testing_tools")
self.file_uri = join(pkgDir, "test_data", "speech_detection_samples", "recording_tuesday.ogg")
self.language = "en"
self.audio_source = "nao_ogg"
self.words = [u"tuesday", u"monday"]
self.sentences = self.words
self.grammar = []
self.user = "rapp"
self.valid_words_found = [u"tuesday"]
def execute(self):
start_time = timeit.default_timer()
response = self.rappCloud.speech_detection_sphinx4(
self.language, self.audio_source, self.words, self.sentences, self.grammar, self.file_uri, self.user
)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response["error"]
if error != "":
return [error, self.elapsed_time]
return_data = response["words"]
if self.valid_words_found == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]
示例13: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
# Configure the call parameters
self.file_uri = __path__ + '/../test_data/YOUR_DATA_HERE_IF_NEEDED'
# Set the valid results
self.valid_results = 0
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.qr_detection(self.file_uri)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response['error']
if error != "":
return [error, self.elapsed_time]
return_data = response['qr_centers']
# Check if the returned data are equal to the expected
if self.valid_results == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]
示例14: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
self.language = 'el'
self.text = u'Καλησπέρα. Είμαι ο ναο.'
self.destFilePath = '/tmp/ttsClient.wav'
# Set the valid results
def execute(self):
start_time = timeit.default_timer()
# Call the Python RappCloud service
response = self.rappCloud.text_to_speech(self.text, self.language,
self.destFilePath)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
if response['error']:
return [response['error'], self.elapsed_time]
# Check if the returned data are equal to the expected
if os.path.getsize(self.destFilePath) > 0:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + 'Invalid size of audio data', self.elapsed_time]
示例15: __init__
class RappInterfaceTest:
def __init__(self):
self.rappCloud = RappCloud()
rospack = rospkg.RosPack()
pkgDir = rospack.get_path("rapp_testing_tools")
self.file_uri = join(pkgDir, "test_data", "qr_samples", "hardFarQr.jpg")
self.valid_results = {
"qr_centers": [{"y": 580, "x": 669}],
"qr_messages": ["This QR will be used to check the algorithmic robustness as it is quite small"],
"error": "",
}
def execute(self):
start_time = timeit.default_timer()
response = self.rappCloud.qr_detection(self.file_uri)
end_time = timeit.default_timer()
self.elapsed_time = end_time - start_time
return self.validate(response)
def validate(self, response):
error = response["error"]
if error != "":
return [error, self.elapsed_time]
return_data = response
if self.valid_results == return_data:
return [True, self.elapsed_time]
else:
return ["Unexpected result : " + str(return_data), self.elapsed_time]