hey Grog and everyone!
I asked the question yesterday if I could pass the text from htmlfilter to a method in my script. Grog you mentioned using subscribe. Well... I cant figure it out. :( Below is my code with the 'talk' method at the bottom that I want to pass the htmlfilter text to. My end game is to get the jaw to move while speaking the alice responses. am i looking at this all wrong?
wksr = Runtime.createAndStart("webkitspeechrecognition", "WebkitSpeechRecognition")
htmlfilter = Runtime.createAndStart("htmlfilter", "HtmlFilter")
mouth = Runtime.createAndStart("mouth", "AcapelaSpeech")
alice = Runtime.createAndStart("alice","ProgramAB")
webGui = Runtime.createAndStart("webGui","WebGui")
voices = mouth.getVoices()
for voice in voices:
mouth.setVoice("will")
# add a link between the webkit speech to publish to ProgramAB
wksr.addTextListener(alice)
# Add route from Program AB to html filter
alice.addTextListener(htmlfilter)
# Add route from html filter to mouth
htmlfilter.addTextListener(mouth)
# talk function
def talk (sent): # this is the bit that makes the mouth move up and down
mouth.speak(sent)
ison = False
a = sent.split()
for word in a:
if word[len(word)-2:] == "es" : # removing es at the end of the word
testword = word[:-2] +'xx' # adding x's to help keep the timing
elif word[len(word)-1:] == "e" : # removing the silant e at the end of the word
testword = word[:-1] +'x'
else:
testword = word
for x in range(0, len(testword)):
if testword[x] in ('a', 'e', 'i', 'o', 'u', 'y' ) and ison == False :
#arduino.digitalWrite(13, Arduino.HIGH)
mouth.moveTo(80) # move the servo to the open spot
ison = True
sleep(0.15)
mouth.moveTo(15) # close the servo
elif testword[x] in ('.') :
#arduino.digitalWrite(13, Arduino.LOW)
ison = False
sleep(.95)
else: #sleep(0.5) sleep half a second
#arduino.digitalWrite(13, Arduino.LOW)
ison = False
sleep(0.06) # sleep half a second
#arduino.digitalWrite(13, Arduino.LOW)
sleep(0.08)
# end of talk function
Ahoy tdp, Cool script - I
Ahoy tdp,
Cool script - I tried it and it was one click worky (except for I had to manually start the alice session)..
I think you added the following lines in an attempt to do what I suggested
I did this and it works for me with your script (albiet - I didn't move the mouth control code or simply call that function - my computer is not attached to mouth servos anyway) - but I did get the filtered text in the onText method i created in python - hopefully this will keep you going ...
Change your Avatar - your not
Change your Avatar - your not a scared gopher anymore ! :D
awesome! this works
awesome! this works perfectly! I will post a video