Trigger Aryan
Wake up Aryan from Sleep
Once AI device is powered on, Aryan gets started in Sleeping mode and waits for Human to Trigger it. A Infinite while loop runs awaiting Human to trigger the Aryan to wake up from Sleep in the AryanStartStopCommand flow.
RawSpeechRecognizationTrigger flow is used to recognize the Human speech and output is stored in ListenSpeech for every 3 sec in loop.
Below code snippet demonstrates this flow and as soon as ListenSpeech matches Aryan or Arya respective flows are triggered by startAI flow.
It is from here that aifriend is identified as Aryan or Arya, they remain with you until Aryan or Arya goes back to sleep.
Terminate Aryan Master
If the Human say "Terminate" then Aryan Master process are shutdown and have to be started again to bring them back to sleep.
Listening to User Speech in Loop
Below snippet is RawSpeechRecognizationTrigger which keeps listening for Human phrase for time limit of 3 sec in loop.
Google Speech Recognition is used to recognize the speech, In case no speech or input then exception is raised but no action is taken and control fall backs to listen again as we want to listen to Human in loop awaiting trigger.
Trigger AI Worker to Start Aryan
Once AI Master get the wakeup command from the Human with AI Friend identified as Aryan or Arya, thereafter AI Worker is triggered which starts the worker script to Start Aryan or Arya using startAI flow
It is accomplished by starting a operating system sub process to start the AIWorker.py script and pass the AI Friend (Aryan or Arya) as parameter.
Variable proc is used to capture the sub process and further monitoring of the child worker by Master.
Monitor Aryan Worker
For the entire Duration when Aryan is in conversation with Human using AI Worker process, AI Master process keeps
Listening for explicit command to Stop AI Worker
Listening to the Human in case Human wants to exit the AI worker explicitly
In this case as soon as the stop trigger words such as "stop", "exit", "no thank you" are identified
the AI Worker process is killed by AI Master using the PID captured while starting the child instance.
and control goes back to starting point i.e. AryanStartStopCommand and AI Master goes back to sleep.
Monitoring for Graceful Exit of AI Worker
Monitoring if AI Worker process exits naturally after completion of the command given by Human.
AI Worker PID is being checked using an Infinite while loop and if poll() for the sub process is None,
that is either the process is killed (PID is removed when exited from the Process table)
or is not functional (Zombie process in Linux)
Thereafter AI Master kills the process
and control goes back to starting point i.e. AryanStartStopCommand and AI Master goes back to sleep.
Phew, Aryan is sleeping again, waiting for Human trigger to wake up again.
Last updated
Was this helpful?