09-12-2009, 10:12 PM
A fun code for the kids. I have been playing with this for awhile. I am an amateur at writing scripts. This works pretty good if you have the correct sapi voices. Run the description code first to see what's on your PC. Probably only works for Microsoft OS though.
Description Code:
Mr. Chatbot Code:
Description Code:
VBS Programming
- Set VObj = CreateObject("SAPI.SpVoice")
- For Each Voice In VObj.getvoices
- I = I + 1
- msgbox "" & (I - 1) & " - " & Voice.GetDescription
- Next
Mr. Chatbot Code:
VBSCRIPT Programming
- Set Vobj = CreateObject("SAPI.SpVoice")
- With Vobj
-
- strName = InputBox("Please choose a voice:" & vbCr & vbCr & "Sam" & vbCr & "Mike" & vbCr & "Mary", "Question:")
-
- Select Case LCase(strName)
- Case "sam"
- Set .voice = .getvoices.item(0)
- .Volume = 100
- .Rate = -3
- Case "mike"
- Set .voice = .getvoices.item(1)
- .Volume = 100
- .Rate = -3
- Case "mary"
- Set .voice = .getvoices.item(2)
- .Volume = 100
- .Rate = -3
- 'Case "Sample TTS"
- ' Set .voice = .getvoices.item(3)
- ' .Volume = 100
- ' .Rate = -3
- Case ""
- WScript.echo "please type a name:"
- End Select
-
- strText = "Hello, my name is " & strName & ". I am a chatbot. Jim created me. What's your name?"'"O.K. See you later then, " & fname & "."
- Vobj.speak strText
-
- fname=InputBox("What's your name?" , "Mr. Chatbot")
- strText = "How are you feeling, " & fname & "?" '"O.K. See you later then, " & fname & "."
- Vobj.speak strText
- ffeeling=InputBox("How are you feeling?" , "Mr. Chatbot")
- strText = "Why are you feeling " & ffeeling & "?"
- Vobj.speak strText
- fanswer=InputBox("Why are you feeling " & ffeeling & "?" , "Mr. Chatbot")
- strText = "Sometimes I feel like that too. What's your favorite color, " & fname & "?"
- Vobj.speak strText
- fcolor=InputBox("What's your favorite color?" , "Mr. Chatbot")
- strText = "I like " & fcolor & ", too. What's your favorite number " & fname & "?"
- Vobj.speak strText
- fnumber=InputBox("What's your favorite number?" , "Mr. Chatbot")
- strText = (fnumber & " is my favorite number too, " & fname & "That is so Cool. We have a lot in common. What else do you like?")
- Vobj.speak strText
- felse=InputBox("What else do you like?" , "Mr. Chatbot")
- strText = "I like " & felse & "too. What is your favorite food, " & fname & "?"
- Vobj.speak strText
- ffood=InputBox("What is your favorite food?" , "Mr. Chatbot")
- strText = "I don't like " & ffood & ". I am a computer. I can't eat food. What is your favorite movie?"
- Vobj.speak strText
- fmovie=InputBox("What's your favorite movie?" , "Mr. Chatbot")
- strText = "Sometimes I have movies on me. I don't think I have ever seen " & fmovie & ". What is your favorite sport " & fname
- Vobj.speak strText
- fsport=InputBox("What is your favorite sport?" , "Mr. chatbot")
- strText = "I can't play " & fsport & "I am a computer. I would rather surf the internet. When you play " & fsport & "you must get thirsty. What is your favorite drink?"
- Vobj.speak strText
- fdrink=InputBox("What is your favorite drink?" , "Mr. Chatbot")
- strText = "Is " & fdrink & "good? Because I can't have fluids. Or I Would Blow Up. What's your favorite game to play?"
- Vobj.speak strText
- fgame=InputBox("What's your favorite game to play?" , "Mr. Chatbot")
- strText = "I have games on me that you could play some day. I don't know if I have " & fgame & "on me but you could look sometime. " & fname & "Did you like talking to me?"
- Vobj.speak strText
- flike=InputBox("Did you like talking to me?" , "Mr. Chatbot")
- strText = "O.K. See you later then, " & fname & ". I will always be here if you need some one to talk to."
- Vobj.speak strText
- MsgBox("GoodBye, " & fname & "!!!") , , "Mr. Chatbot"
- End With