Skip to content

Commit 99237bc

Browse files
author
luyishisi
committed
aiml-test-2
1 parent 5b1ebe1 commit 99237bc

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

python_aiml_test/start/brain-2.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import aiml
2+
import os
3+
import subprocess
4+
kernel = aiml.Kernel()
5+
6+
if os.path.isfile("rebot_brain.brn"):
7+
kernel.bootstrap(brainFile = "rebot_brain.brn")
8+
else:
9+
kernel.bootstrap(learnFiles = "std-startup.xml", commands = "load aiml pattern")
10+
kernel.saveBrain("rebot_brain.brn")
11+
# kernel = aiml.Kernel()
12+
# kernel.learn("std-startup.xml")
13+
# kernel.respond("load aiml pattern")
14+
print("begin game")
15+
a = "http://tsn.baidu.com/text2audio?tex=hello, you can talk to me! just tell me&lan=zh&per=0&pit=5&spd=2&cuid=7519663&ctp=1&tok=24.91b892cbba2c73d07f9fba69182b7960.2592000.1456136364.282335-7519663&qq-pf-to=pcqq.c2c"
16+
subprocess.call(["mpg123",a])
17+
rebot = "rebot say: hello, you can talk to me! Just tell me "
18+
print (rebot)
19+
while True:
20+
message = raw_input("I say: ")
21+
if message == "quit":
22+
exit()
23+
elif message == "save":
24+
kernel.saveBrain("rebot_brain.brn")
25+
elif message == "ch":
26+
print ("rebot say: Cherry! You find me!How did you know my creator??")
27+
else:
28+
bot_response = kernel.respond(message)
29+
say = 'http://tsn.baidu.com/text2audio?tex='+bot_response+'&lan=zh&per=0&pit=5&spd=2&cuid=7519663&ctp=1&tok=24.91b892cbba2c73d07f9fba69182b7960.2592000.1456136364.282335-7519663&qq-pf-to=pcqq.c2c'
30+
print ("robot say: %s" % bot_response)
31+
b= subprocess.call(["mpg123",say,">1.txt"],shell=True,stdout=1)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#coding:utf-8
2+
import subprocess
3+
subprocess.call(["mpg123","http://tsn.baidu.com/text2audio?tex=hello my name is luyi&lan=zh&per=0&pit=5&spd=2&cuid=7519663&ctp=1&tok=24.91b892cbba2c73d07f9fba69182b7960.2592000.1456136364.282335-7519663&qq-pf-to=pcqq.c2c"])
4+
#subprocess.call(["mpg123","http://music.baidutt.com/up/kwcawskw/dsskw.mp3"])

0 commit comments

Comments
 (0)