Hi ! Program AB doesn't like quotes ( ex: I'M A BOT ) it must be ( I M A BOT ) I think

And I want to correct some ear values.

So how can i intercept WebkitSpeechRecognition  and replace some characters before ProgramAB read it.

Thanks !

beetlejuice

8 years 5 months ago

Hi !

Here is a quick exemple ( mayby not the better, but that work ! )

Runtime.createAndStart("chatBot", "ProgramAB") 
sleep (1)
chatBot.startSession( "default", "wikidataFR") 
Runtime.createAndStart("ear", "WebkitSpeechRecognition") 
mouth=Runtime.createAndStart("mouth", "AcapelaSpeech")
htmlFilter=Runtime.createAndStart("htmlFilter", "HtmlFilter")

sleep(1)
ear.addListener("publishText", python.name, "talk") 
# Add route from Program AB to html filter
chatBot.addTextListener(htmlFilter)
# Add route from html filter to mouth
htmlFilter.addListener("publishText", python.name, "say");
mouth.setLanguage("FR");
mouth.setVoice("Antoine");
ear.setLanguage("fr-FR")
Runtime.createAndStart("webGui", "WebGui") 

def say(data):
	mouth.speakBlocking(data)
	print "chatbot :", data
	
def talk(data):
	if data!="":
		data = data.replace("\'", " ") # Replace quote by a blank space
		chatBot.getResponse(data) # Ask the chatBot 
  		print "chatbot :", data

 

You need to have this category in your aiml file.

<category>
<pattern>SAY *</pattern>
<template><star /></template>

</category>

moz4r

8 years 5 months ago

Correct me if i wrong but It works but not really :) , why  :

QUEL EST LE fruit DE L'abricotier

the paterne called is :

<category><pattern>QUEL EST LE * DE *</pattern>

AND NOT

<category><pattern>QUEL EST LE * DE L'*</pattern>

I want to use this outside the wikidata service in classic aiml pattern

So the talk function is not called at this time. I need to intercept the data before ProgramAB fetch it . Any idea ?

this is the tip : ( remove chatbot listener )

#ear.addTextListener(chatBot) 

def onText(text):
 print text.replace("'", " ")
 chatBot.getResponse(text.replace("'", " "))
 
python.subscribe(ear.getName(),"publishText")