So the question came up in the forums about repedative questions to the ProgramAB.
So I started to look at the call for starting and using the ProgramAB service.
 
In the Manticore version, this is the example code:
 
#########################################
# ProgramAB.py
#########################################
 
# create a ProgramAB service and start a session
alice = Runtime.start("alice", "ProgramAB")
alice.startSession("username")
 
print alice.getResponse("How are you?")
 
# create a Speech service
mouth = Runtime.start("mouth", "MarySpeech")
# create a route which sends published Responses to the
# mouth.speak(String) method
alice.addTextListener(mouth)
 
alice.getResponse(u"What is new?")
sleep(3)
alice.getResponse(u"Tell me a joke?")
sleep(3)
alice.getResponse(u"What time is it?")
sleep(3)
# UTF8 test
alice.getResponse(u"こんにちは")
 
 
In the new Nixie version the example code is more like 
-
 
So next stop for me is the JavaDocs
where I find the following
void addTextListener​(SpeechSynthesis service) Deprecated.
void addTextListener​(TextListener service) Deprecated.
void addTextPublisher​(TextPublisher service) Deprecated.
 
So is there a new example showing how to use this complex service?
 
I found somewhere, can't remember where the adding in the text listener to the Speech To Text service and found it works
But now I see the points I used are depreciated.
So there must be a better way!
I just don't know what it is.
 
Ray
 

GroG

2 years 8 months ago

Hi Ray,

Always good questions from you.

attachTextListener(TextListener listener)
attachTextPublisher(TextPublisher publisher)

should be the only methods you need - SpeechSynthesis is also a TextListener

Here is a pretty ascii diagram describing a service's life cycle

create service --> load config --> start service --> attaching phase -->  (service ready)

(service ready) --> stop service --> release service from registry

many service can only "attach" to one other type of service.
so I want to simplify attaching methods and remove other forms of attaching like addListener methods..
 

e.g.
servo.attach(arduino)
arduino.attach(servo)
mouth.attach(brain)
brain.attach(ear)

If order and no other parameters are needed, and they are re-entrant, these methods become simple to use from the perspective of the consumer.