Subscribe to htmlfilter

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:
# add a link between the webkit speech to publish to ProgramAB
# Add route from Program AB to html filter
# Add route from html filter to mouth
# talk function
def talk (sent): # this is the bit that makes the mouth move up and down 
  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'
      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
        mouth.moveTo(15) # close the servo 
      elif testword[x] in ('.') :
        #arduino.digitalWrite(13, Arduino.LOW)
        ison = False
      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)
# end of talk function


GroG's picture

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

# Add route from html filter to mouth
But that isnt quite right...
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 ...
GroG's picture

Change your Avatar - your not

Change your Avatar - your not a scared gopher anymore ! :D

tdp378's picture

awesome! this works

awesome! this works perfectly!  I will post a video