-
Notifications
You must be signed in to change notification settings - Fork 18
/
chattyBot.py
38 lines (31 loc) · 880 Bytes
/
chattyBot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This is a voice-output interface for CleverBot, a chatbot.
# Needs python3, cleverwrap and flite chattyto run
# python should be present in a unix terminal
#
# pip install cleverwrap
# sudo apt-get install flite
#
# Usage:
# python chatBot.py
# then just type after the > prompt
# to leave, type > I'm leaving
from cleverwrap import CleverWrap
chatBot = CleverWrap("CC6zkRgO9TPlPcz6AO_zLCunNBg")
import subprocess
import sys
shell = True
#chatBot.reset()
def speak(this):
print('- '+str(this))
subprocess.run(['flite', '-voice', 'file://cmu_us_aew.flitevox', '-t', str(this)])
speak('I\'m listening')
var = input('> ')
chatting = True
while chatting == True:
if(var == 'I\'m leaving'):
chatting = False
break
reply = chatBot.say(str(var))
speak(reply)
var = input('> ')
speak("Fine, leave. See if I care.")