-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbot_conversation.py
More file actions
33 lines (18 loc) · 811 Bytes
/
bot_conversation.py
File metadata and controls
33 lines (18 loc) · 811 Bytes
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
from recordingbot import Bot
import os
conversationfn = 'conv.txt' # create this file on first run
converations = {}
with open(conversationfn, 'r') as conv: # run create_conversation_log.py to generate this
for line in conv.read().split("\n"):
if "#" in line:
text, fn = line.split("#")
converations.update({text : fn})
class ConversationBot(Bot):
def process(self, text, memberid, timestamp, wavefn):
newfn = "{}!{}!{}".format(memberid, timestamp, text.replace(" ", "_") + ".wav")
os.rename(wavefn, os.path.join(self.datapath, newfn))
if text in converations:
self.play(converations[text])
if __name__ == "__main__":
bot = ConversationBot('voicedata', 'voiceapi.json')
bot.run()