diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-12-30 19:52:57 +0100 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-12-30 19:52:57 +0100 |
| commit | ec3e900b05d07b228f68ed2ab42bfd545ac06b92 (patch) | |
| tree | 1a9d93728f5edfaa049ddfad2639a3c5cdb64793 /tests/test_stt.py | |
| parent | 74b2639b574ecaf600798d234d93e2d807f63021 (diff) | |
| parent | 87262c75c3e645358e6587b64c8bd2adca9477b2 (diff) | |
| download | jasper-client-ec3e900b05d07b228f68ed2ab42bfd545ac06b92.tar.gz jasper-client-ec3e900b05d07b228f68ed2ab42bfd545ac06b92.zip | |
Merge pull request #270 from Holzhaus/split-unittests
Split unittests into separate files and move them to tests/
Diffstat (limited to 'tests/test_stt.py')
| -rw-r--r-- | tests/test_stt.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_stt.py b/tests/test_stt.py new file mode 100644 index 0000000..cb33ff6 --- /dev/null +++ b/tests/test_stt.py @@ -0,0 +1,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) |
