Skip to content

Commit 3c9b3e2

Browse files
committed
Added speech detection tests using samples from NAO
1 parent fb3fc3c commit 3c9b3e2

22 files changed

+907
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
#MIT License (MIT)
5+
6+
#Copyright (c) <2014> <Rapp Project EU>
7+
8+
#Permission is hereby granted, free of charge, to any person obtaining a copy
9+
#of this software and associated documentation files (the "Software"), to deal
10+
#in the Software without restriction, including without limitation the rights
11+
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
#copies of the Software, and to permit persons to whom the Software is
13+
#furnished to do so, subject to the following conditions:
14+
15+
#The above copyright notice and this permission notice shall be included in
16+
#all copies or substantial portions of the Software.
17+
18+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
#THE SOFTWARE.
25+
26+
# Authors: Konstantinos Panayiotou, Manos Tsardoulias
27+
28+
29+
30+
import sys
31+
import os
32+
import timeit
33+
import argparse
34+
35+
__path__ = os.path.dirname(os.path.realpath(__file__))
36+
37+
## ------ Access the RappCloud python module ------- ##
38+
from RappCloud import RappCloud
39+
40+
class RappInterfaceTest:
41+
42+
def __init__(self):
43+
self.rappCloud = RappCloud()
44+
self.file_uri = __path__ + '/../test_data/speech_detection_samples/recording_sentence1.ogg'
45+
self.valid_words_found = ['I', 'want', 'to', 'go', 'out']
46+
47+
def execute(self):
48+
start_time = timeit.default_timer()
49+
response = self.rappCloud.speech_detection_google(self.file_uri)
50+
end_time = timeit.default_timer()
51+
self.elapsed_time = end_time - start_time
52+
return self.validate(response)
53+
54+
def validate(self, response):
55+
error = response['error']
56+
if error != "":
57+
return [error, self.elapsed_time]
58+
59+
return_data = response['words']
60+
if self.valid_words_found == return_data:
61+
return [True, self.elapsed_time]
62+
else:
63+
return ["Unexpected result : " + str(return_data), self.elapsed_time]
64+
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
#MIT License (MIT)
5+
6+
#Copyright (c) <2014> <Rapp Project EU>
7+
8+
#Permission is hereby granted, free of charge, to any person obtaining a copy
9+
#of this software and associated documentation files (the "Software"), to deal
10+
#in the Software without restriction, including without limitation the rights
11+
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
#copies of the Software, and to permit persons to whom the Software is
13+
#furnished to do so, subject to the following conditions:
14+
15+
#The above copyright notice and this permission notice shall be included in
16+
#all copies or substantial portions of the Software.
17+
18+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
#THE SOFTWARE.
25+
26+
# Authors: Konstantinos Panayiotou, Manos Tsardoulias
27+
28+
29+
30+
import sys
31+
import os
32+
import timeit
33+
import argparse
34+
35+
__path__ = os.path.dirname(os.path.realpath(__file__))
36+
37+
## ------ Access the RappCloud python module ------- ##
38+
from RappCloud import RappCloud
39+
40+
class RappInterfaceTest:
41+
42+
def __init__(self):
43+
self.rappCloud = RappCloud()
44+
self.file_uri = __path__ + '/../test_data/speech_detection_samples/recording_sentence2.ogg'
45+
self.valid_words_found = ['Check', 'my', 'emails']
46+
47+
def execute(self):
48+
start_time = timeit.default_timer()
49+
response = self.rappCloud.speech_detection_google(self.file_uri)
50+
end_time = timeit.default_timer()
51+
self.elapsed_time = end_time - start_time
52+
return self.validate(response)
53+
54+
def validate(self, response):
55+
error = response['error']
56+
if error != "":
57+
return [error, self.elapsed_time]
58+
59+
return_data = response['words']
60+
if self.valid_words_found == return_data:
61+
return [True, self.elapsed_time]
62+
else:
63+
return ["Unexpected result : " + str(return_data), self.elapsed_time]
64+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
#MIT License (MIT)
5+
6+
#Copyright (c) <2014> <Rapp Project EU>
7+
8+
#Permission is hereby granted, free of charge, to any person obtaining a copy
9+
#of this software and associated documentation files (the "Software"), to deal
10+
#in the Software without restriction, including without limitation the rights
11+
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
#copies of the Software, and to permit persons to whom the Software is
13+
#furnished to do so, subject to the following conditions:
14+
15+
#The above copyright notice and this permission notice shall be included in
16+
#all copies or substantial portions of the Software.
17+
18+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
#THE SOFTWARE.
25+
26+
# Authors: Konstantinos Panayiotou, Manos Tsardoulias
27+
28+
29+
30+
import sys
31+
import os
32+
import timeit
33+
import argparse
34+
35+
__path__ = os.path.dirname(os.path.realpath(__file__))
36+
37+
## ------ Access the RappCloud python module ------- ##
38+
from RappCloud import RappCloud
39+
40+
class RappInterfaceTest:
41+
42+
def __init__(self):
43+
self.rappCloud = RappCloud()
44+
self.file_uri = __path__ + '/../test_data/speech_detection_samples/recording_sentence1.ogg'
45+
self.language = 'en'
46+
self.audio_source = 'nao_ogg'
47+
self.words = []
48+
self.sentences = self.words
49+
self.grammar = []
50+
self.user = 'rapp'
51+
self.valid_words_found = [u'yes']
52+
53+
def execute(self):
54+
55+
start_time = timeit.default_timer()
56+
response = self.rappCloud.speech_detection_sphinx4(\
57+
self.language,\
58+
self.audio_source,\
59+
self.words,\
60+
self.sentences,\
61+
self.grammar,\
62+
self.file_uri,\
63+
self.user)
64+
end_time = timeit.default_timer()
65+
self.elapsed_time = end_time - start_time
66+
return self.validate(response)
67+
68+
def validate(self, response):
69+
error = response['error']
70+
if error != "":
71+
return [error, self.elapsed_time]
72+
73+
return_data = response['words']
74+
if self.valid_words_found == return_data:
75+
return [True, self.elapsed_time]
76+
else:
77+
return ["Unexpected result : " + str(return_data), self.elapsed_time]
78+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
#MIT License (MIT)
5+
6+
#Copyright (c) <2014> <Rapp Project EU>
7+
8+
#Permission is hereby granted, free of charge, to any person obtaining a copy
9+
#of this software and associated documentation files (the "Software"), to deal
10+
#in the Software without restriction, including without limitation the rights
11+
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
#copies of the Software, and to permit persons to whom the Software is
13+
#furnished to do so, subject to the following conditions:
14+
15+
#The above copyright notice and this permission notice shall be included in
16+
#all copies or substantial portions of the Software.
17+
18+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
#THE SOFTWARE.
25+
26+
# Authors: Konstantinos Panayiotou, Manos Tsardoulias
27+
28+
29+
30+
import sys
31+
import os
32+
import timeit
33+
import argparse
34+
35+
__path__ = os.path.dirname(os.path.realpath(__file__))
36+
37+
## ------ Access the RappCloud python module ------- ##
38+
from RappCloud import RappCloud
39+
40+
class RappInterfaceTest:
41+
42+
def __init__(self):
43+
self.rappCloud = RappCloud()
44+
self.file_uri = __path__ + '/../test_data/speech_detection_samples/recording_sentence2.ogg'
45+
self.language = 'en'
46+
self.audio_source = 'nao_ogg'
47+
self.words = []
48+
self.sentences = self.words
49+
self.grammar = []
50+
self.user = 'rapp'
51+
self.valid_words_found = [u'yes']
52+
53+
def execute(self):
54+
55+
start_time = timeit.default_timer()
56+
response = self.rappCloud.speech_detection_sphinx4(\
57+
self.language,\
58+
self.audio_source,\
59+
self.words,\
60+
self.sentences,\
61+
self.grammar,\
62+
self.file_uri,\
63+
self.user)
64+
end_time = timeit.default_timer()
65+
self.elapsed_time = end_time - start_time
66+
return self.validate(response)
67+
68+
def validate(self, response):
69+
error = response['error']
70+
if error != "":
71+
return [error, self.elapsed_time]
72+
73+
return_data = response['words']
74+
if self.valid_words_found == return_data:
75+
return [True, self.elapsed_time]
76+
else:
77+
return ["Unexpected result : " + str(return_data), self.elapsed_time]
78+
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
#MIT License (MIT)
5+
6+
#Copyright (c) <2014> <Rapp Project EU>
7+
8+
#Permission is hereby granted, free of charge, to any person obtaining a copy
9+
#of this software and associated documentation files (the "Software"), to deal
10+
#in the Software without restriction, including without limitation the rights
11+
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
#copies of the Software, and to permit persons to whom the Software is
13+
#furnished to do so, subject to the following conditions:
14+
15+
#The above copyright notice and this permission notice shall be included in
16+
#all copies or substantial portions of the Software.
17+
18+
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
#THE SOFTWARE.
25+
26+
# Authors: Konstantinos Panayiotou, Manos Tsardoulias
27+
28+
29+
30+
import sys
31+
import os
32+
import timeit
33+
import argparse
34+
35+
__path__ = os.path.dirname(os.path.realpath(__file__))
36+
37+
## ------ Access the RappCloud python module ------- ##
38+
from RappCloud import RappCloud
39+
40+
class RappInterfaceTest:
41+
42+
def __init__(self):
43+
self.rappCloud = RappCloud()
44+
self.file_uri = __path__ + '/../test_data/speech_detection_samples/recording_deutera.ogg'
45+
self.language = 'gr'
46+
self.audio_source = 'nao_ogg'
47+
self.words = [u'τριτη', u'δευτερα']
48+
self.sentences = self.words
49+
self.grammar = []
50+
self.user = 'rapp'
51+
self.valid_words_found = [u'δευτερα']
52+
53+
def execute(self):
54+
55+
start_time = timeit.default_timer()
56+
response = self.rappCloud.speech_detection_sphinx4(\
57+
self.language,\
58+
self.audio_source,\
59+
self.words,\
60+
self.sentences,\
61+
self.grammar,\
62+
self.file_uri,\
63+
self.user)
64+
end_time = timeit.default_timer()
65+
self.elapsed_time = end_time - start_time
66+
return self.validate(response)
67+
68+
def validate(self, response):
69+
error = response['error']
70+
if error != "":
71+
return [error, self.elapsed_time]
72+
73+
return_data = response['words']
74+
if self.valid_words_found == return_data:
75+
return [True, self.elapsed_time]
76+
else:
77+
return ["Unexpected result : " + str(return_data), self.elapsed_time]
78+

0 commit comments

Comments
 (0)