Skip to content
This repository was archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #292 from Wolfgange3311999/bugfix/temp-file
Browse files Browse the repository at this point in the history
Temp dict files now have generated names in /tmp/
  • Loading branch information
aatchison authored Jul 15, 2016
2 parents f3a9004 + 11cdc72 commit 993fe22
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions mycroft/client/speech/local_recognizer.py
Original file line number Diff line number Diff line change
@@ -39,13 +39,10 @@ def __init__(self, key_phrase, phonemes, threshold, sample_rate=16000,
self.decoder = Decoder(self.create_config(dict_name))

def create_dict(self, key_phrase, phonemes):
folder = os.path.join(tempfile.gettempdir(), 'mycroft')
if not os.path.exists(folder):
os.makedirs(folder)
file_name = os.path.join(folder, key_phrase + ".dict")
(fd, file_name) = tempfile.mkstemp()
words = key_phrase.split()
phoneme_groups = phonemes.split('.')
with open(file_name, 'w') as f:
with os.fdopen(fd, 'w') as f:
for word, phoneme in zip(words, phoneme_groups):
f.write(word + ' ' + phoneme + '\n')
return file_name

0 comments on commit 993fe22

Please sign in to comment.