gunthercox/chatterbot-voice

global name 'WindowsError' is not defined on OSX

Closed this issue · 6 comments

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
bot = ChatBot(
... "Tiberius",
... input_adapter="chatterbot_voice.VoiceInput",
... output_adapter="chatterbot_voice.VoiceOutput",
... )
File "~/lib/python2.7/site-packages/chatterbot_voice/voice.py", line 49, in attempt_jack_control_start
except WindowsError:
NameError: global name 'WindowsError' is not defined

Anything special to do on OSX, to make it work?

Apologies @baskin, I'll have to make changes to fix this since WindowsError is specific to Windows. I'm surprised this issue hasn't come up before since I use Linux a lot.

Thanks @gunthercox. When can you get around to the fix?

Possibly this weekend.

I also come cross this problem. Error is happen at 👍
def attempt_jack_control_start(self):
"""
Jack is a program that can be used to get audio
input from your system. This command will try
to start it when your program runs.
"""
try:
subprocess.call(['jack_control', 'start'])
except WindowsError:
# jack_control is not a valid command in Windows
pass
except Exception:
warnings.warn(
'Unable to start jack control.',
RuntimeWarning
)

I've removed the line that was referencing the Windows-specific exception type. I have also released version 0.1.3 of this package which includes this fix.

output_adapter="chatterbot_voice.VoiceOutput",
File "/usr/local/lib/python2.7/dist-packages/chatterbot/chatterbot.py", line 38, in init
self.input = utils.initialize_class(input_adapter, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/chatterbot/utils.py", line 33, in initialize_class
return Class(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/chatterbot_voice/voice.py", line 22, in init
self.attempt_jack_control_start()
File "/usr/local/lib/python2.7/dist-packages/chatterbot_voice/voice.py", line 51, in attempt_jack_control_start
warnings.warn(
NameError: global name 'warnings' is not defined

how to fix it