• warning: file_get_contents(https://raw.githubusercontent.com/MyRobotLab/pyrobotlab/master//home/beetlejuice/wikiDataFetcher%2BAB%2BFR.py) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /var/www/html/myrobotlab/themes/superclean/repoFile.php on line 25.
  • warning: file_get_contents(https://raw.githubusercontent.com/MyRobotLab/pyrobotlab/master//home/beetlejuice/wikiDataFetcher%2BAB%2BFR.py) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /var/www/html/myrobotlab/themes/superclean/repoFile.php on line 30.

WebkitSpeechRecognition interception before programAB

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's picture

Hi !Here is a quick exemple

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>

beetlejuice's picture

But ProgramAB work with

But ProgramAB work with quotes, you have to use UTF-8, have a look here:


#file : /home/beetlejuice/wikiDataFetcher%2BAB%2BFR.py edit raw

moz4r's picture

merci beetle !!!! I will try

merci beetle !!!!

I will try it

moz4r's picture

Correct me if i wrong but It

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 ?

moz4r's picture

I foundt it

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")