-
Notifications
You must be signed in to change notification settings - Fork 1k
/
test_stt.py
51 lines (41 loc) · 1.42 KB
/
test_stt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python2
# -*- coding: utf-8-*-
import unittest
import imp
from client import stt, jasperpath
def cmuclmtk_installed():
try:
imp.find_module('cmuclmtk')
except ImportError:
return False
else:
return True
def pocketsphinx_installed():
try:
imp.find_module('pocketsphinx')
except ImportError:
return False
else:
return True
@unittest.skipUnless(cmuclmtk_installed(), "CMUCLMTK not present")
@unittest.skipUnless(pocketsphinx_installed(), "Pocketsphinx not present")
class TestSTT(unittest.TestCase):
def setUp(self):
self.jasper_clip = jasperpath.data('audio', 'jasper.wav')
self.time_clip = jasperpath.data('audio', 'time.wav')
self.passive_stt_engine = stt.PocketSphinxSTT.get_passive_instance()
self.active_stt_engine = stt.PocketSphinxSTT.get_active_instance()
def testTranscribeJasper(self):
"""
Does Jasper recognize his name (i.e., passive listen)?
"""
with open(self.jasper_clip, mode="rb") as f:
transcription = self.passive_stt_engine.transcribe(f)
self.assertIn("JASPER", transcription)
def testTranscribe(self):
"""
Does Jasper recognize 'time' (i.e., active listen)?
"""
with open(self.time_clip, mode="rb") as f:
transcription = self.active_stt_engine.transcribe(f)
self.assertIn("TIME", transcription)