python - Check inside for loop is not executed -
i working on project make computer speak when give commands. started, when run code, doesn't respond in way expect respond. here code:
from pocketsphinx import livespeech import os phrase in livespeech(): print(phrase) if phrase == 'oh' : os.system('espeak' ' "hi"')
i got error when run code. here error:
traceback (most recent call last): file "xxt", line 4, in <module> print(phrase) file "/library/python/2.7/site-packages/pocketsphinx/__init__.py", line 93, in __str__ return self.hypothesis() file "/library/python/2.7/site-packages/pocketsphinx/__init__.py", line 126, in hypothesis hyp = self.hyp() file "/library/python/2.7/site-packages/pocketsphinx/pocketsphinx.py", line 359, in hyp return _pocketsphinx.decoder_hyp(self) file "/library/python/2.7/site-packages/pocketsphinx/__init__.py", line 225, in stop raise stopiteration stopiteration
thanks, aditya
this because if statement not in loop, loop's body print statement
for phrase in livespeech(): print(phrase) if phrase == 'oh' : os.system('espeak' ' "hi"')
this should like
Comments
Post a Comment