VERSION 5.00 Object = "{2398E321-5C6E-11D1-8C65-0060081841DE}#1.0#0"; "Vtext.dll" Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX" Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX" Object = "{C1A8AF28-1257-101B-8FB0-0020AF039CA3}#1.1#0"; "MCI32.OCX" Begin VB.Form frmMain BorderStyle = 1 'Fixed Single ClientHeight = 8505 ClientLeft = 15 ClientTop = 15 ClientWidth = 11700 ControlBox = 0 'False Icon = "frmMain.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False Moveable = 0 'False ScaleHeight = 8505 ScaleWidth = 11700 StartUpPosition = 2 'CenterScreen WindowState = 2 'Maximized Begin VB.CommandButton cmdHide Appearance = 0 'Flat Height = 375 Left = 0 TabIndex = 17 Top = 0 Width = 495 End Begin MCI.MMControl MMControl1 Height = 375 Left = 840 TabIndex = 16 Top = 5640 Width = 420 _ExtentX = 741 _ExtentY = 661 _Version = 393216 BorderStyle = 0 PrevVisible = 0 'False NextVisible = 0 'False PlayVisible = 0 'False PauseVisible = 0 'False BackVisible = 0 'False StepVisible = 0 'False StopVisible = 0 'False RecordVisible = 0 'False EjectVisible = 0 'False DeviceType = "" FileName = "" End Begin VB.Frame Frame1 Caption = "Mode" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1335 Left = 120 TabIndex = 11 Top = 6960 Width = 2775 Begin VB.OptionButton OptNeutral Caption = "Neutral" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 1560 TabIndex = 15 Top = 840 Width = 1095 End Begin VB.OptionButton OptAngry Caption = "Angry" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 1560 TabIndex = 14 Top = 360 Width = 1095 End Begin VB.OptionButton OptSad Caption = "Sad" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 240 TabIndex = 13 Top = 840 Width = 1215 End Begin VB.OptionButton OptHappy Caption = "Happy" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 240 TabIndex = 12 Top = 360 Width = 1215 End End Begin VB.Timer Timer2 Interval = 100 Left = 600 Top = 6120 End Begin MSWinsockLib.Winsock Winsock1 Left = 1080 Top = 6120 _ExtentX = 741 _ExtentY = 741 _Version = 393216 End Begin VB.TextBox txtRecv BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 345 Left = 1560 TabIndex = 6 Top = 600 Width = 2775 End Begin VB.Timer Timer1 Interval = 1000 Left = 120 Top = 6120 End Begin VB.CommandButton cmdQuit Caption = "Quit" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 10440 TabIndex = 4 Top = 7560 Width = 1095 End Begin VB.CommandButton cmdSpeak Caption = "Speak" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 10440 TabIndex = 3 Top = 6600 Width = 1095 End Begin VB.TextBox txtOutput Height = 975 Left = 8640 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 2 Top = 720 Width = 2775 End Begin VB.ComboBox Combo1 Height = 315 Left = 1560 TabIndex = 1 Text = "Combo1" Top = 120 Width = 2775 End Begin MSCommLib.MSComm MSComm1 Left = 120 Top = 5520 _ExtentX = 1005 _ExtentY = 1005 _Version = 393216 DTREnable = -1 'True End Begin HTTSLibCtl.TextToSpeech TextToSpeech1 Height = 6615 Left = 960 OleObjectBlob = "frmMain.frx":0442 TabIndex = 0 Top = 1920 Width = 9735 End Begin VB.Label Label4 Caption = "Status:" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 7680 TabIndex = 10 Top = 120 Width = 735 End Begin VB.Label lblStatus BorderStyle = 1 'Fixed Single Height = 495 Left = 8640 TabIndex = 9 Top = 120 Width = 2775 End Begin VB.Label Label3 Caption = "Voice:" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 720 TabIndex = 8 Top = 120 Width = 735 End Begin VB.Label Label2 Caption = "Input:" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 720 TabIndex = 7 Top = 600 Width = 735 End Begin VB.Label Label1 Caption = "Output:" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 7680 TabIndex = 5 Top = 840 Width = 855 End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False '************************************************************ ' ' ZAZA Robot Voice Program ' ' Mike Drennan - Tech Museum of Innovation ' Last modified April 24, 2001 ' '************************************************************ Option Explicit Dim LastEntry As Date Dim Hidden As Boolean Dim RandomSpeech As Boolean Dim SND0 As String 'Sound files Dim SND1 As String Dim SND2 As String Dim SND3 As String Dim SND4 As String Dim SND5 As String Dim SND6 As String Dim SND7 As String Dim SND8 As String Dim SND9 As String Private Sub HideControls() On Error GoTo Errorhandler If Not Hidden Then Frame1.Visible = False Combo1.Visible = False Label1.Visible = False Label2.Visible = False Label3.Visible = False Label4.Visible = False lblStatus.Visible = False cmdSpeak.Visible = False cmdQuit.Visible = False txtOutput.Visible = False txtRecv.Visible = False MMControl1.Visible = False Hidden = True Else Frame1.Visible = True Combo1.Visible = True Label1.Visible = True Label2.Visible = True Label3.Visible = True Label4.Visible = True lblStatus.Visible = True cmdSpeak.Visible = True cmdQuit.Visible = True txtOutput.Visible = True txtRecv.Visible = True MMControl1.Visible = True Hidden = False End If Exit Sub Errorhandler: Display_Error ("Hide_Controls") End Sub Private Sub cmdHide_Click() On Error GoTo Errorhandler HideControls Exit Sub Errorhandler: Display_Error ("cmdHide_Click") End Sub Private Sub cmdQuit_Click() On Error GoTo Errorhandler MMControl1.Command = "Close" End Exit Sub Errorhandler: Display_Error ("cmdQuit_Click") End Sub Private Sub cmdSpeak_Click() On Error GoTo Errorhandler If txtOutput.Text <> "" Then TextToSpeech1.Speak txtOutput.Text End If Exit Sub Errorhandler: Display_Error ("cmdSpeak_Click") End Sub Private Sub Form_Load() Dim ModeName As String Dim engine Dim i On Error GoTo Errorhandler LastEntry = Now RandomSpeech = False If App.PrevInstance = True Then Unload Me Exit Sub End If 'Read data file Read_INI 'Load sound files Load_Sound 'Close port if open - then go into Listen mode If Winsock1.State <> 0 Then Winsock1.Close Winsock1.LocalPort = Val("101") Winsock1.Listen 'Configure Speech Engine engine = TextToSpeech1.Find("Mfg=Microsoft;Gender=1") TextToSpeech1.Select engine For i = 1 To TextToSpeech1.CountEngines ModeName = TextToSpeech1.ModeName(i) Combo1.AddItem ModeName Next i Combo1.ListIndex = TextToSpeech1.CurrentMode - 1 'Set mouth position to default settings TextToSpeech1.MouthHeight = 8 TextToSpeech1.MouthUpturn = 195 TextToSpeech1.TeethUpperVisible = 4 TextToSpeech1.TeethLowerVisible = 1 'Make the controls invisible HideControls Exit Sub Errorhandler: Display_Error ("Form_Load") End Sub Private Sub Combo1_Click() On Error GoTo Errorhandler Rem Each time somebody selects a new voice/engine/mode from the combo box, Rem select that voice as the active speaker. TextToSpeech1.CurrentMode = Combo1.ListIndex + 1 Rem Set the gender of the lips..Gender=1 means female. If (TextToSpeech1.Gender(TextToSpeech1.CurrentMode) = 1) Then TextToSpeech1.LipType = 0 'female full red lips Else TextToSpeech1.LipType = 1 'male thinner paler lips End If Exit Sub Errorhandler: Display_Error ("Combo1_Click") End Sub Private Sub OptAngry_Click() On Error GoTo Errorhandler TextToSpeech1.MouthUpturn = 0 OptAngry.Value = True Exit Sub Errorhandler: Display_Error ("OptAngry_Click") End Sub Private Sub OptHappy_Click() On Error GoTo Errorhandler TextToSpeech1.MouthUpturn = 255 OptHappy.Value = True Exit Sub Errorhandler: Display_Error ("OptHappy_Click") End Sub Private Sub OptNeutral_Click() On Error GoTo Errorhandler TextToSpeech1.MouthUpturn = 128 OptNeutral.Value = True Exit Sub Errorhandler: Display_Error ("OptNeutral_Click") End Sub Private Sub OptSad_Click() On Error GoTo Errorhandler TextToSpeech1.MouthUpturn = 0 OptSad.Value = True Exit Sub Errorhandler: Display_Error ("OptSad_Click") End Sub Private Sub Timer1_Timer() On Error GoTo Errorhandler 'If RandomSpeech is TRUE and 30 seconds have elapsed then say a phrase If RandomSpeech And DateDiff("s", LastEntry, Now) > 30 Then SayRandom End If Exit Sub Errorhandler: Display_Error ("Timer1_Timer") End Sub Private Sub SayRandom() On Error GoTo Errorhandler Dim Selection Selection = Int((12 * Rnd) + 1) Select Case Selection Case 1: TextToSpeech1.Speak "Hello. My name is Zaw zaw. What's yours?" Case 2: TextToSpeech1.Speak "Do you like robots?" Case 3: TextToSpeech1.Speak "Welcome to the Tech Museum of Innovation" Case 4: TextToSpeech1.Speak "The time is " & Time Case 5: TextToSpeech1.Speak "Have a nice day!" Case 6: TextToSpeech1.Speak "I think I'll go over there." Case 7: TextToSpeech1.Speak "What kind of robot are you?" Case 8: TextToSpeech1.Speak "Can someone direct me to an electrical outlet?" Case 9: TextToSpeech1.Speak "Robots rock!" Case 10: TextToSpeech1.Speak "What do you do when a robot rolls his eyes at you? You pick them up and give them back!" Case 11: TextToSpeech1.Speak "Are you an android?" Case 12: TextToSpeech1.Speak "This is a nice place to visit... but I live here!" Case Else: End Select LastEntry = Now Exit Sub Errorhandler: Display_Error ("SayRandom") End Sub Private Sub Winsock_Status() On Error GoTo Errorhandler Dim status$ 'Display communications status Select Case Winsock1.State Case 0: status = "Closed" Case 1: status = "Open" Case 2: status = "Listening" Case 3: status = "Connection Pending" Case 4: status = "Resolving Host" Case 5: status = "Host Resolved" Case 6: status = "Connecting..." Case 7: status = "Connected" Case 8: status = "Peer is closing connection" Case 9: status = "Error" Case Else: status = "Unknown" End Select lblStatus.Caption = status 'If client closes connection, go back to Listen mode If Winsock1.State = 8 Then Disconnect End If Exit Sub Errorhandler: Display_Error ("Winsock_Status") End Sub Private Sub Timer2_Timer() On Error GoTo Errorhandler Winsock_Status Exit Sub Errorhandler: Display_Error ("Timer2_Timer") End Sub Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) On Error GoTo Errorhandler 'Accept client connection If Winsock1.State <> sckClosed Then Winsock1.Close Winsock1.Accept (requestID) Exit Sub Errorhandler: Display_Error ("Winsock1_ConnectionRequest") End Sub Private Sub Winsock1_DataArrival(ByVal bytestotal As Long) On Error GoTo Errorhandler Dim DataIncoming As String Winsock1.GetData DataIncoming, vbString, bytestotal txtRecv.Text = txtRecv.Text & DataIncoming 'Do we have a complete string? If InStr(1, DataIncoming, vbCrLf) Then Set_Mode If Len(txtRecv.Text) <> 0 Then TextToSpeech1.Speak txtRecv.Text End If txtRecv.Text = "" End If LastEntry = Now Exit Sub Errorhandler: Display_Error ("Winsock1_DataArrival") End Sub Private Sub Disconnect() On Error GoTo Errorhandler Winsock1.Close Winsock1.LocalPort = Val("101") Winsock1.Listen Exit Sub Errorhandler: Display_Error ("Disconnect") End Sub Private Sub Set_Mode() On Error GoTo Errorhandler Dim Position As Long Dim Mode As String Dim MouthIndex As String On Error Resume Next 'Check for first mode in string If Len(txtRecv.Text) > 3 Then Position = InStr(1, txtRecv.Text, "/", 1) If Position <> 0 Then txtRecv.Text = Mid(txtRecv.Text, Position) Mode = Mid(txtRecv.Text, 2, 2) Execute_Mode (Mode) End If End If 'Loop until done Do While MMControl1.Mode = 526 DoEvents Loop 'Check for second mode If Len(txtRecv.Text) > 3 Then Position = InStr(1, txtRecv.Text, "/", 1) If Position <> 0 Then txtRecv.Text = Mid(txtRecv.Text, Position) Mode = Mid(txtRecv.Text, 2, 2) Execute_Mode (Mode) End If End If 'Loop until done Do While MMControl1.Mode = 526 DoEvents Loop 'Check for third mode If Len(txtRecv.Text) > 3 Then Position = InStr(1, txtRecv.Text, "/", 1) If Position <> 0 Then txtRecv.Text = Mid(txtRecv.Text, Position) Mode = Mid(txtRecv.Text, 2, 2) Execute_Mode (Mode) End If End If 'Loop until done Do While MMControl1.Mode = 526 DoEvents Loop 'Check for fourth mode If Len(txtRecv.Text) > 3 Then Position = InStr(1, txtRecv.Text, "/", 1) If Position <> 0 Then txtRecv.Text = Mid(txtRecv.Text, Position) Mode = Mid(txtRecv.Text, 2, 2) Execute_Mode (Mode) End If End If Exit Sub Errorhandler: Display_Error ("Set_Mode") End Sub Private Sub Execute_Mode(Mode As String) On Error GoTo Errorhandler 'Find Mode Directives Select Case UCase(Mode) Case "R0": RandomSpeech = False txtRecv.Text = Mid(txtRecv.Text, 4) Case "R1": RandomSpeech = True txtRecv.Text = Mid(txtRecv.Text, 4) Case "EN": OptNeutral_Click txtRecv.Text = Mid(txtRecv.Text, 4) Case "EH": OptHappy_Click txtRecv.Text = Mid(txtRecv.Text, 4) Case "EA": OptAngry_Click txtRecv.Text = Mid(txtRecv.Text, 4) Case "ES": OptSad_Click txtRecv.Text = Mid(txtRecv.Text, 4) Case "S0": Play_Sound (0) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S1": Play_Sound (1) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S2": Play_Sound (2) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S3": Play_Sound (3) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S4": Play_Sound (4) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S5": Play_Sound (5) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S6": Play_Sound (6) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S7": Play_Sound (7) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S8": Play_Sound (8) txtRecv.Text = Mid(txtRecv.Text, 4) Case "S9": Play_Sound (9) txtRecv.Text = Mid(txtRecv.Text, 4) Case "MU": If Len(txtRecv.Text) > 5 Then MouthUpturn (Mid(txtRecv.Text, 4, 3)) txtRecv.Text = Mid(txtRecv.Text, 7) Else 'Error - not enough chars txtRecv.Text = "" End If Case Else End Select Exit Sub Errorhandler: Display_Error ("Execute_Mode") End Sub Private Sub Read_INI() On Error GoTo Errorhandler Dim textline As String 'Open and read INI file If Not (Dir(App.Path & "\zaza.ini") <> "") Then MsgBox "Cannot find ZAZA.INI. Exiting.", vbOKOnly, "Resource Error." End If Open App.Path & "\ZAZA.INI" For Input As #1 'Read values from INI file that will turn bits on and off Do While Not EOF(1) Line Input #1, textline If UCase(Left$(textline, 5)) = "SND0=" Then SND0 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND1=" Then SND1 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND2=" Then SND2 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND3=" Then SND3 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND4=" Then SND4 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND5=" Then SND5 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND6=" Then SND6 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND7=" Then SND7 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND8=" Then SND8 = Mid$(textline, 6, (Len(textline) - 5)) If UCase(Left$(textline, 5)) = "SND9=" Then SND9 = Mid$(textline, 6, (Len(textline) - 5)) Loop 'Close the data file Close #1 Exit Sub Errorhandler: Display_Error ("Read_INI") End Sub Private Sub Load_Sound() On Error GoTo Errorhandler MMControl1.Notify = False MMControl1.Wait = True MMControl1.Shareable = False MMControl1.DeviceType = "WaveAudio" If Not (Dir(App.Path & "\" & SND0) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND0 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND1) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND1 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND2) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND2 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND3) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND3 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND4) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND4 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND5) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND5 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND6) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND6 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND7) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND7 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND8) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND8 & "...Exiting.", vbOKOnly, "Resource Error." End If If Not (Dir(App.Path & "\" & SND9) <> "") Then MsgBox "Cannot find " & App.Path & "\" & SND9 & "...Exiting.", vbOKOnly, "Resource Error." End If Exit Sub Errorhandler: Display_Error ("Load_Sound") End Sub Private Sub Play_Sound(sound As Integer) On Error GoTo Errorhandler MMControl1.Command = "Close" Select Case sound Case 0 MMControl1.FileName = App.Path & "\" & SND0 MMControl1.Command = "open" Case 1 MMControl1.FileName = App.Path & "\" & SND1 MMControl1.Command = "open" Case 2 MMControl1.FileName = App.Path & "\" & SND2 MMControl1.Command = "open" Case 3 MMControl1.FileName = App.Path & "\" & SND3 MMControl1.Command = "open" Case 4 MMControl1.FileName = App.Path & "\" & SND4 MMControl1.Command = "open" Case 5 MMControl1.FileName = App.Path & "\" & SND5 MMControl1.Command = "open" Case 6 MMControl1.FileName = App.Path & "\" & SND6 MMControl1.Command = "open" Case 7 MMControl1.FileName = App.Path & "\" & SND7 MMControl1.Command = "open" Case 8 MMControl1.FileName = App.Path & "\" & SND8 MMControl1.Command = "open" Case 9 MMControl1.FileName = App.Path & "\" & SND9 MMControl1.Command = "open" Case Else End Select MMControl1.Command = "Play" Exit Sub Errorhandler: Display_Error ("Play_Sound") End Sub Private Sub MouthUpturn(MouthIndex As Integer) On Error GoTo Errorhandler If MouthIndex < 256 Then TextToSpeech1.MouthUpturn = MouthIndex End If Exit Sub Errorhandler: Display_Error ("MouthUpturn") End Sub Public Sub Display_Error(routine As String) ' Check for error, then show message ' If Err.Number <> 0 Then MsgBox "Error # " & Str$(Err.Number) & " was generated by " & Err.Source & Chr(13) & Err.Description & " in routine " & routine ' Write the error to the log ' Open (App.Path & "\ERROR.LOG") For Append As #1 Write #1, Now & " Error # " & Str$(Err.Number) & " was generated by " & Err.Source & Chr(13) & Err.Description & " in routine " & routine Close #1 End If End Sub