diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-15 14:35:01 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-25 20:08:09 +0200 |
| commit | 02a095af1ed7af338384d39d43906bb47d1591a7 (patch) | |
| tree | 901dd3d056167889394a9f40c1f0c2443b9cdb95 /client/stt.py | |
| parent | b2e96c73dc0e20b21074d3648796b54509be17f2 (diff) | |
| download | jasper-client-02a095af1ed7af338384d39d43906bb47d1591a7.tar.gz jasper-client-02a095af1ed7af338384d39d43906bb47d1591a7.zip | |
STT engines now inherit from AbstractSTTEngine
Diffstat (limited to 'client/stt.py')
| -rw-r--r-- | client/stt.py | 20 |
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 |
