X
23Jan

Xamarin Forms- Dependency Service (Text To Speech)

It is beautiful  and simple to implement. We can use this feature in our App where we want to add voice with text.

 

Prerequisite :- Xamarin Forms project with PCL Approach.

(STEP 1)

Create a Interface class in PCL.

Right click on PCL project ->Add New-> EmptyInterface Create this Interface class with the name of “ItextToSpeech”.

Create a Method inside the class as I am showing in image.

Interface

Now, an interface is done.

(STEP 2)

Implement interface method platform wise.

First we will do it for Android.

Write click on .Droid project and Add a new class with the name of “TtImplementation”.

RightClick->Add New-> EmptyClass

Now we need to do implementation of that method which we have created in Interface. For doing this just follow my screen shot.

DroidImplementation

Here implementation of “Speak ” method in .Droid is done.

 

(STEP 3)

FOR IOS

Here  we will do same. We will create a new class with the name of “TtImplementation” in iOS project.

For creating this just Right click on .iOS project -> Add New-> EmptyClass.

For implementing Speak method which we have created in interface just follow my screen shot.

iOSImplementation

Now all implementation is done. We have successfully implemented TextToSpeech feature in our Xamarin Forms project without using any plugin.

Now it’s time to check how it is working in both platform.

So for testing I have created simple application. Which I am going to show you. So just follow my instruction.

(STEP 4)

Create UI & Functionality  for testing.

I have create a very simple UI, I have taken 2 Entry,1 Button and 1 label control.

Go to your Main.xaml file open it and write code as I have written in following screen shot.

UI

you can see it in this screen shot I have created a simple Ui.

And that Ui part is done.

As I mentation previously I have taken a button. so for that button I have also created a Click event.

Now Open MainPage.xaml.cs file in your PCL Project.

And write code as I have written in screen shot.

UICS

In Code you can see I am taking value entry1 and entry2 and on click event I have written a program for SUM.And result will populate in level.

See the highlited part, in that section what ever value is getting on label that would be speak.

now you we can test it. Just build the program and deployed on your simulator.

After that enter the value and click on ADD button.

Now you able listen result.

ScreenShot2018-01-23...

 

Conclusion

Now we have done good practice for TextToSpeech.

We can implement it in our project based on requirement.

We don’t need to use any Plugin for this feature.

Related

LDAP Integration with Sonatype Nexus

Sonatype Nexus supports the Repository Manager integration with various active directory systems for...

Read More >

Swift Mapping and Flat Mapping

In this blog post, I will introduce some of useful tips and techniques of using swift mapping and fl...

Read More >

Software Services

The whole world has come to realize the role played by Information Technology and looking at ways to...

Read More >

Microsoft Dynamics NAV 2018 User Task

User Tasks is a one of the new feature added in Microsoft Dynamics NAV 2018.In this you can create t...

Read More >

Swift Closures

In this blog post we will learn what is a closure, it's syntax and types of closures in Swift with e...

Read More >

Bugzilla to TFS Migrator (Part 4 of 4) - Migration

This is the final part of the Bugzilla to TFS Migrator blog series covering the actual steps of migr...

Read More >

Webinar - Streamline Software Development Using Microsoft ALM

Please watch the LIVE RECORDING Video of the webinar session below which took place on 3rd...

Read More >

Creating a Simple Form with Validation Using ASP.NET MVC 4 Empty Template

There are multiple Validation attributes available in MVC. Validation attributes comes from System.C...

Read More >

Mobile Apps

There are mobile applications and then there are Applications done by Canarys. Smart phones and tabl...

Read More >

Sonar Integration with TFS for Java Projects

 Sonar Integration with JAVA.1.Download sonar-3.7 and sonar-runner-2.3*** unzip folders and cop...

Read More >

Share

Post a Comment

Try DevOpSmartBoard Ultimate complete Azure DevOps End-to end reporting tool

Sign Up

  • Recent
  • Popular
  • Tag
Monthly Archive
Subscribe
Name

Text/HTML
Text/HTML
Contact Us
  • *
  • *