diff options
| author | schneefux <schneefux+commit@schneefux.xyz> | 2014-09-27 14:41:02 +0200 |
|---|---|---|
| committer | schneefux <schneefux+commit@schneefux.xyz> | 2014-10-08 20:52:14 +0200 |
| commit | 0aacc7df0f106cbca991c2d7d0d86d5ec3abafad (patch) | |
| tree | 4fc28eab6890aaaed38aec33423fd73e5fd3a87a | |
| parent | 382c21d2ec5ca18d6932d38db8c23432aeac33dd (diff) | |
| download | jasper-client-0aacc7df0f106cbca991c2d7d0d86d5ec3abafad.tar.gz jasper-client-0aacc7df0f106cbca991c2d7d0d86d5ec3abafad.zip | |
Add method to get keyword phrases to vocabcompiler
This way they can be used by other STT engines as well
| -rw-r--r-- | client/vocabcompiler.py | 20 | ||||
| -rw-r--r-- | static/keyword_phrases | 18 |
2 files changed, 38 insertions, 0 deletions
diff --git a/client/vocabcompiler.py b/client/vocabcompiler.py index c59bd6e..8edee6f 100644 --- a/client/vocabcompiler.py +++ b/client/vocabcompiler.py @@ -12,6 +12,8 @@ from abc import ABCMeta, abstractmethod, abstractproperty import g2p import brain +import jasperpath + try: import cmuclmtk except ImportError: @@ -333,6 +335,24 @@ def get_phrases_from_module(module): return module.WORDS if hasattr(module, 'WORDS') else [] +def get_keyword_phrases(): + """ + Gets the keyword phrases from the keywords file in the jasper data dir. + + Returns: + A list of keyword phrases. + """ + phrases = [] + + with open(jasperpath.data('keyword_phrases'), mode="r") as f: + for line in f: + phrase = line.strip() + if phrase: + phrases.append(phrase) + + return phrases + + def get_all_phrases(): """ Gets phrases from all modules. diff --git a/static/keyword_phrases b/static/keyword_phrases new file mode 100644 index 0000000..d118b13 --- /dev/null +++ b/static/keyword_phrases @@ -0,0 +1,18 @@ +BE +BEING +BUT +DID +FIRST +IN +IS +IT +JASPER +NOW +OF +ON +RIGHT +SAY +WHAT +WHICH +WITH +WORK
\ No newline at end of file |
