summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorschneefux <schneefux+commit@schneefux.xyz>2014-09-16 00:40:56 -0400
committerschneefux <schneefux+commit@schneefux.xyz>2014-09-16 00:40:56 -0400
commit560c9d2b076c759829a15a155bc821de5d9e48ba (patch)
treedfdc61ccb54b3f823857b2a1f71e75dfae66ce41 /client
parent4712b530f02d6ff5db259809f7ebd28b268e4cbf (diff)
parent2503ece871ac2d405c5851ffefe5d61b263896d5 (diff)
downloadjasper-client-560c9d2b076c759829a15a155bc821de5d9e48ba.tar.gz
jasper-client-560c9d2b076c759829a15a155bc821de5d9e48ba.zip
Merge pull request #175 from Holzhaus/vocabcompiler-pathfix
Use `Brain.get_modules()` in vocabcompiler
Diffstat (limited to 'client')
-rw-r--r--client/vocabcompiler.py23
1 files changed, 5 insertions, 18 deletions
diff --git a/client/vocabcompiler.py b/client/vocabcompiler.py
index 1b4d94c..9bc34d2 100644
--- a/client/vocabcompiler.py
+++ b/client/vocabcompiler.py
@@ -4,14 +4,8 @@
"""
import os
-import sys
-import glob
-
-mod_path = os.path.abspath('modules/')
-
-sys.path.append(mod_path)
-
import g2p
+from brain import Brain
def text2lm(in_filename, out_filename):
@@ -35,21 +29,14 @@ def compile(sentences, dictionary, languagemodel):
Gets the words and creates the dictionary
"""
- m = [os.path.basename(f)[:-3]
- for f in glob.glob(os.path.dirname("../client/modules/") + "/*.py")]
+ modules = Brain.get_modules()
words = []
- for module_name in m:
- try:
- exec("import %s" % module_name)
- eval("words.extend(%s.WORDS)" % module_name)
- except:
- pass # module probably doesn't have the property
-
- words = list(set(words))
-
+ for module in modules:
+ words.extend(module.WORDS)
# for spotify module
words.extend(["MUSIC", "SPOTIFY"])
+ words = list(set(words))
# create the dictionary
pronounced = g2p.translateWords(words)