
Did you ever thought of building a Uipath robot which actually speaks to you?
Cool!!!, if you have already done it that’s fine, Congratulations to you on that thing.
I think you can still enjoy playing the game at least 🙂
If you didn’t and wondering how to implement that, we have got you something here.
No worries 🙂
Let’s see how to implement it step-by-step !!!
Example
Implementation using UiPath :
Let us implement a fun game, where we will try to ask the user a few questions and we will surprise him with the robot’s prediction (Forgive me if I fail to surprise you because it’s totally your fault and blame yourself for being too clever and brilliant ha-ha!!! )
Major Steps:
1. Setting the environment
2. Asking the questions
3. Predicting the result
Step 1:
As a first thing, please add
System.Speech to the . Xaml file that you are currently working on using notepad as shown below
Step 2:
Drag “Sequence” activity into the designer panel and create two variables as shown below which we will be using later.
“WelcomeMsg” variable of String type
“Syn” variable of SpeechSynthesizer type
(***The SpeechSynthesizer class provides access to the functionality of a speech synthesis engine that is installed on the host computer)
Step 3:
Drag “Assign” activity into the designer panel and assign the welcome message along with the question that you want to ask the user.
Use “Environment.UserName” to get the current Username
Step 4:
Drag “Assign” activity to set Volume property of SpeechSynthesizer object for now as shown below
Different available properties:
1. Rate – Resembles speech rate ie Ranges from -10 to 10 where zero is the normal speed
2. Volume – Allows you to set the volume
3. State – Gets the current speaking state
4. Voice – Gets information about the current voice
Step 5:
Aim: Here let us welcome the user and ask him to choose a number between 1 to 10.
Drag “Invoke” activity and write the below code into it and pass the required arguments as shown
Step 6:
Aim: Here let us ask him to add 3 to it.
Drag a few activities similar to the above step and write the below code into it and pass the required arguments as shown to ask questions to the user.
Step 7:
Aim: Here let us ask him to Multiply it by 2.
Since we have been using “Invoke Code” to speak to the user, let’s see how to do the same in another way using “Invoke Method” activity.
Drag “Invoke Method” into the designer panel and pass the required arguments as shown to ask questions to the user.
And similarly, implement the rest of the questions…
Step 8:
Aim: Here let us ask him to subtract 4 from it.
Step 9:
Aim: Here let us ask him to divide it by 2.
Step 10:
Aim: Here let us ask him to subtract your number from it.
Step 11:
Aim: Surprise him with the result by announcing the number he is now left with.
Step 12:
Finally, execute the workflow to see it working 🙂
All the best!!!
Click here to download the Source Code…
Hope it has helped you…