With thanks to Yii Toh King for the construction of the audio input circuit.
The talking head was constructed from a kit supplied by Milford Instruments was made and mouth movement made to move with audio input from this circuit. The animaton board was discarded and the head interfaced to a PC using the 8 Servo Driver board from Milford Instruments. The idea behind the head was to create a tour guide for the labs who could talk about certain subjects and depended on the input from the audience.
The Microsoft Speech SDK was downloaded and incorporated into a Visual Basic program. The program also controlled Alex's head movements depending on what he was saying. Certain keywords (e.g. 'LEFT', 'RIGHT') would cause him to look in the various directions. The mouth moved using the audio input and his eyes rolled about randomly. A future addition to this project would be to incorporate speech recognition to allow him to interact with the audience.
The Visual Basic code appears below:
'0-head left/right
'1-eyes
'2-head up/down
Option Explicit
Public WithEvents Voice As SpeechLib.SpVoice
Dim speakFlags As SpeechVoiceSpeakFlags
Private Sub headleft()
MSComm1.Output = Chr$(255) + Chr$(0) + Chr$(1)
End Sub
Private Sub headright()
MSComm1.Output = Chr$(255) + Chr$(0) + Chr$(255)
End Sub
Private Sub headup()
MSComm1.Output = Chr$(255) + Chr$(2) + Chr$(1)
End Sub
Private Sub headdown()
MSComm1.Output = Chr$(255) + Chr$(2) + Chr$(255)
End Sub
Private Sub headshake()
Dim n As Integer
For n = 1 To 3
MSComm1.Output = Chr$(255) + Chr$(0) + Chr$(255)
pause
MSComm1.Output = Chr$(255) + Chr$(0) + Chr$(1)
pause
Next n
MSComm1.Output = Chr$(255) + Chr$(0) + Chr$(128)
End Sub
Private Sub headcentre()
MSComm1.Output = Chr$(255) + Chr$(0) + Chr$(128)
MSComm1.Output = Chr$(255) + Chr$(1) + Chr$(128)
MSComm1.Output = Chr$(255) + Chr$(2) + Chr$(128)
End Sub
Private Sub headnod()
Dim n As Integer
For n = 1 To 3
MSComm1.Output = Chr$(255) + Chr$(2) + Chr$(255)
pause
MSComm1.Output = Chr$(255) + Chr$(2) + Chr$(1)
pause
Next n
MSComm1.Output = Chr$(255) + Chr$(2) + Chr$(128)
End Sub
Private Sub eyesleft()
MSComm1.Output = Chr$(255) + Chr$(1) + Chr$(255)
End Sub
Private Sub eyesright()
MSComm1.Output = Chr$(255) + Chr$(1) + Chr$(1)
End Sub
Private Sub Command1_Click()
headleft
End Sub
Private Sub Command3_Click()
headright
End Sub
Private Sub Command4_Click()
headup
End Sub
Private Sub Command5_Click()
headdown
End Sub
Private Sub Command6_Click()
headcentre
End Sub
Private Sub Command7_Click()
headshake
End Sub
Private Sub EyesL_Click()
eyesleft
End Sub
Private Sub EyesR_Click()
eyesright
End Sub
Private Sub Nod_Click()
headnod
End Sub
Private Sub pause()
t = 1
Do While t < 5
DoEvents
Loop
End Sub
Private Sub Form_Load()
' Use COM1.
MSComm1.CommPort = 1
' 9600 baud, no parity, 8 data, and 1 stop bit.
MSComm1.Settings = "9600,N,8,1"
' Tell the control to read entire buffer when Input
' is used.
MSComm1.InputLen = 0
' Open the port.
MSComm1.PortOpen = True
Timer1.Interval = 1
Timer1.Enabled = True
' Creates the voice object first
Set Voice = New SpVoice
headcentre
End Sub
Private Sub Command2_Click()
MSComm1.PortOpen = False
Unload Form1
End Sub
Private Sub Timer1_Timer()
t = t + 1
End Sub
Private Sub Speak_Click()
headcentre
Voice.Speak Text1.Text, SVSFlagsAsync
End Sub
Private Sub Voice_Word(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal CharacterPosition As Long, ByVal Length As Long)
' In order to show this selection,
' the Text1.HideSelection property must be False!
Text1.SelStart = CharacterPosition
Text1.SelLength = Length
mannerisms = Mid$(Text1.Text, CharacterPosition + 1, Length)
If (mannerisms = "left") Then headleft
If (mannerisms = "right") Then headright
If (mannerisms = "up") Then headup
If (mannerisms = "above") Then headup
If (mannerisms = "below") Then headdown
If (mannerisms = "no") Then headshake
If (mannerisms = "yes") Then headnod
If Length < 4 Then eyesleft
If Length >= 4 Then eyesright
End Sub