Text-To-Speech Example – In UiPath

UiPath Text to speech
@austindistel #Unsplash

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 !!!

SignUp To Get Free ReFramework Templates

* indicates required

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

Text To Speech Example 1.PNG

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)

Text To Speech Example 2.png

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

Text To Speech Example 3

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

Text To Speech Example 4.PNG

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

Text To Speech Example 5Text To Speech Example 6

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.

Text To Speech Example 7.PNG

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.

Text To Speech Example 8.PNG

And similarly, implement the rest of the questions…

Text To Speech Example 9.PNG

Step 8:
Aim: Here let us ask him to subtract 4 from it.

Text To Speech Example 10.PNG

Step 9:
Aim: Here let us ask him to divide it by 2.

Text To Speech Example 11.PNG

Step 10:
Aim: Here let us ask him to subtract your number from it.

Text To Speech Example 12.PNG

Step 11:
Aim: Surprise him with the result by announcing the number he is now left with.

Text To Speech Example 13.PNG

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…

Leave a Reply

%d bloggers like this: