summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-15 14:35:01 +0200
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-25 20:08:09 +0200
commit02a095af1ed7af338384d39d43906bb47d1591a7 (patch)
tree901dd3d056167889394a9f40c1f0c2443b9cdb95
parentb2e96c73dc0e20b21074d3648796b54509be17f2 (diff)
downloadjasper-client-02a095af1ed7af338384d39d43906bb47d1591a7.tar.gz
jasper-client-02a095af1ed7af338384d39d43906bb47d1591a7.zip
STT engines now inherit from AbstractSTTEngine
-rw-r--r--client/stt.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/client/stt.py b/client/stt.py
index a937658..9a8bb61 100644
--- a/client/stt.py
+++ b/client/stt.py
@@ -5,6 +5,7 @@ import traceback
import json
import tempfile
import logging
+from abc import ABCMeta, abstractmethod
import requests
import yaml
@@ -12,8 +13,23 @@ import yaml
The default Speech-to-Text implementation which relies on PocketSphinx.
"""
+class AbstractSTTEngine(object):
+ """
+ Generic parent class for all STT engines
+ """
-class PocketSphinxSTT(object):
+ __metaclass__ = ABCMeta
+
+ @classmethod
+ @abstractmethod
+ def is_available(cls):
+ return True
+
+ @abstractmethod
+ def transcribe(self, audio_file_path, PERSONA_ONLY=False, MUSIC=False):
+ pass
+
+class PocketSphinxSTT(AbstractSTTEngine):
def __init__(self, lmd="languagemodel.lm", dictd="dictionary.dic",
lmd_persona="languagemodel_persona.lm", dictd_persona="dictionary_persona.dic",
@@ -134,7 +150,7 @@ Excerpt from sample profile.yml:
"""
-class GoogleSTT(object):
+class GoogleSTT(AbstractSTTEngine):
RATE = 16000