I'm trying to make a script with speech recognition. So I have 3 files. 1 file is listening to what I'm saying and then printing it to a file. The other script is reading the file and answer depending on what the file is saying. The third script is just starting the 2 other scripts
1st script(stt.py):
import os
import pyttsx
import sys
from pocketsphinx import LiveSpeech, get_model_path
engine = pyttsx.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', 'english+f3')
f = open("test.out", 'w')
sys.stdout = f
model_path = get_model_path()
speech = LiveSpeech(
verbose=False,
sampling_rate=16000,
buffer_size=2048,
no_search=False,
full_utt=False,
hmm=os.path.join(model_path, 'en-us'),
lm=os.path.join(model_path, 'en-us.lm.bin'),
dic=os.path.join(model_path, 'cmudict-en-us.dict')
)
f = open("test.out", 'w')
sys.stdout = f
for phrase in speech:
print (phrase)
f.write ("end")
2st script (speak.py):
import pyttsx
import sys
engine = pyttsx.init()
voices = engine.getProperty('voices')
f = open("test.out", 'w')
sys.stdout = f
volume = engine.getProperty('volume')
engine.setProperty('voice', 'english+f3')
engine.setProperty('volume', volume-0.10)
engine.say("good morning master, I'm Moas. How can I help you?")
engine.runAndWait
if 'start' in open('test.out').read():
engine.say("Hello Admin")
else:
engine.say("I did not understand")
engine.runAndWait()
3rd script (start.py)
execfile("speak.py")
execfile("stt.py")
So when I start "start.py" It opens terminal, says " goodmorning master, im moas how can i help you, i did not understand". Then it just sits and wait for nothing. If I only run "speak.py" it says the same thing like above and then shuts down.
What I want the file to do is to check the file every 10th second to see if it has changed and then answer depending on what the file is saying.
Anyone got any ideas?