Close

Adding storytelling to the robot. A great educational tool for small children!

A project log for Anna The Multibot!

Multifunctional robot to help bring the dream of a personal robot into reality.

dennisDennis 08/04/2016 at 01:390 Comments

With a working voice on the robot, it is a good time to add a practical automatic function such as storytelling. With a voice-coordinated head motion and a display to display the words being spoken, a storytelling robot could be a great educational tool to teach reading skills to small children. I could also see other educational functions to teach math, science and history. Lots of robot kits are designed to teach engineering, but why not have a robot to help teach other subjects as well.

I added a new form to display the story. The form contains a “rich” textbox and 3 buttons for pause, resume and cancel. The display will display one sentence at a time as the robot tells the story so a child can read along.
The below images shows the display, the code to handle the buttons and what the display looks like while the robot is telling the story. In the future, the display will be on the robot:

To the “command class” I added the following code to decode the command to tell a story:
If command_input.Contains("tell") And command_input.Contains("story") Then
Speech.speak_text("ok...")
story()
End If
Also under “command" class I added the following sub to load the story and call the read sub.

Private Sub story()
Anna.Command_text.Text = Nothing
Anna.load_story()
Anna.read_text()
End Sub
In the main class I added the following subs to load the story, tell the story and handle buttons to pause, resume and cancel the story and also automate some head motion to keep the viewers’ attention:
Public Sub load_story()
Try
' Open the file using a stream reader.
Using sr As New StreamReader("C:\Anna\Anna_Robot_Project\Anna\story\jack and the beanstalk.txt")
Dim line As String
' Read the stream to a string and write the string to the console.
line = sr.ReadToEnd()
s = line
End Using
Catch

End Try
'TextBox1.Text = s
End Sub
Public Sub read_text()
Dim first_index As Integer
Dim second_index As Integer
Dim length As Integer
Dim segment As String = Nothing
Dim myForm2 As New Display()
first_index = -1

display_cancel = False
Do
second_index = (s.IndexOf(".", second_index + 1))
length = second_index - (first_index)
If length < 1 Then Exit Do
segment = s.Substring(first_index + 1, length)
myForm2.Show()
myForm2.RichTextBox1.Text = segment
first_index = second_index
speech1(segment)
If second_index > s.Length - 1 Then Exit Do
Dim a As String = segment.Length
If display_cancel = True Then Exit Do
Loop
myForm2.Close()
End Sub
Private Sub speech1(st As String)
synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult)
speaker.Rate = 0
speaker.Volume = 100
AddHandler speaker.SpeakCompleted, AddressOf SpeachComplete
speaker.SpeakAsync(st)
speech_head_motion()
While speach_done = False
Application.DoEvents()
If display_cancel = True Then Exit While
End While
speach_done = False
End Sub
Private Sub SpeachComplete(sender As Object, e As SpeakCompletedEventArgs)
speach_done = True
End Sub
Public Sub speach_pause()
speaker.Pause()
Speech.speak_text("Story is paused")
End Sub
Public Sub speach_resume()
Speech.speak_text("Story is resuming")
Threading.Thread.Sleep(500)
speaker.Resume()
End Sub
Public Sub speach_stop()
display_cancel = True
speaker.SpeakAsyncCancelAll()
Speech.speak_text("Story is terminated")
End Sub
Private Sub speech_head_motion()
head_up(800)
head_speech_count = head_speech_count + 3
If head_speech_count > 10 Then head_speech_count = 0
If head_speech_count > 8 Then head_forward()
If head_speech_count > 8 Then head_up(500)
If head_speech_count > 5 And head_speech_count < 8 Then head_left(500)
If head_speech_count < 5 Then head_right(500)
End Sub

Discussions