Skip to content

Commit cc51f6a

Browse files
committed
aiml-test
1 parent c685629 commit cc51f6a

46 files changed

Lines changed: 175142 additions & 1 deletion

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

python_aiml_rebot

Lines changed: 0 additions & 1 deletion
This file was deleted.

python_aiml_test/1.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Text To Speech using SAPI (Windows) and Python module pyTTS by Peter Parente
2+
# download installer file pyTTS-3.0.win32-py2.4.exe
3+
# from: http://sourceforge.net/projects/uncassist
4+
# also needs: http://www.cs.unc.edu/Research/assist/packages/SAPI5SpeechInstaller.msi
5+
# and pywin32-204.win32-py2.4.exe at this date the latest version of win32com
6+
# from: http://sourceforge.net/projects/pywin32/
7+
# tested with Python24 on a Windows XP computer vagaseat 15jun2005
8+
import pyTTS
9+
import time
10+
tts = pyTTS.Create()
11+
# set the speech rate, higher value = faster
12+
# just for fun try values of -10 to 10
13+
tts.Rate = 1
14+
print "Speech rate =", tts.Rate
15+
# set the speech volume percentage (0-100%)
16+
tts.Volume = 90
17+
print "Speech volume =", tts.Volume
18+
# get a list of all the available voices
19+
print "List of voices =", tts.GetVoiceNames()
20+
# explicitly set a voice
21+
tts.SetVoiceByName('MSMary')
22+
print "Voice is set ot MSMary"
23+
print
24+
# announce the date and time, does a good job
25+
timeStr = "The date and time is " + time.asctime()
26+
print timeStr
27+
tts.Speak(timeStr)
28+
print
29+
str1 = """
30+
A young executive was leaving the office at 6 pm when he found
31+
the CEO standing in front of a shredder with a piece of paper in hand.
32+
"Listen," said the CEO, "this is important, and my secretary has left.
33+
Can you make this thing work?"
34+
"Certainly," said the young executive. He turned the machine on,
35+
inserted the paper, and pressed the start button.
36+
"Excellent, excellent!" said the CEO as his paper disappeared inside
37+
the machine. "I just need one copy."
38+
"""
39+
print str1
40+
tts.Speak(str1)
41+
tts.Speak('Haah haa haah haa')
42+
print
43+
str2 = """
44+
Finagle's fourth law:
45+
Once a job is fouled up, anything done to improve it only makes it worse.
46+
"""
47+
print str2
48+
print
49+
print "The spoken text above has been written to a wave file (.wav)"
50+
tts.SpeakToWave('Finagle4.wav', str2)
51+
print "The wave file is loaded back and spoken ..."
52+
tts.SpeakFromWave('Finagle4.wav')
53+
print
54+
print "Substitute a hard to pronounce word like Ctrl key ..."
55+
#create an instance of the pronunciation corrector
56+
p = pyTTS.Pronounce()
57+
# replace words that are hard to pronounce with something that
58+
# is spelled out or misspelled, but at least sounds like it
59+
p.AddMisspelled('Ctrl', 'Control')
60+
str3 = p.Correct('Please press the Ctrl key!')
61+
tts.Speak(str3)
62+
print
63+
print "2 * 3 = 6"
64+
tts.Speak('2 * 3 = 6')
65+
print
66+
tts.Speak("sounds goofy, let's replace * with times")
67+
print "Substitute * with times"
68+
# ' * ' needs the spaces
69+
p.AddMisspelled(' * ', 'times')
70+
str4 = p.Correct('2 * 3 = 6')
71+
tts.Speak(str4)
72+
print
73+
print "Say that real fast a few times!"
74+
str5 = "The sinking steamer sunk!"
75+
tts.Rate = 3
76+
for k in range(7):
77+
print str5
78+
tts.Speak(str5)
79+
time.sleep(0.3)
80+
tts.Rate = 0
81+
tts.Speak("Wow, not one mispronounced word!")

python_aiml_test/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# python_aiml_rebot
2+
#Required python tools aiml
3+
run commend like
4+
`sudo apt-get install python-aiml`
5+
6+
##Introduction:
7+
1. Use python tools aiml to bulit a talk-rebot.
8+
2. Still not complete Chinese language yet.Please wait.
9+
3. But it can support python commend like 'quit'(exit()) and so on, just write what you want!And tell the reboot to execute it.
10+
11+
##Quick start:
12+
```
13+
git clone https://github.com/ch710798472/python_aiml_rebot.git
14+
cd python_aiml_rebot/start
15+
python brain.py
16+
```
17+
18+
#### And then you can talk to him or her like this:
19+
```
20+
you say: hello
21+
bot say: What can I call you?
22+
you say: cc
23+
bot say: Nice to meet you Cc.
24+
you say:你好
25+
bot say:你好啊!
26+
you say:quit
27+
```
28+
#### Then you will exit the program

0 commit comments

Comments
 (0)