Introduction
Xamarin.Essentials
Xamarin.Essentials provides developers with cross-platform APIs for their
mobile applications. Android, iOS, and UWP offer unique operating system and
platform APIs that developers have access to all in C# leveraging Xamarin.
Xamarin.Essentials provides a single cross-platform API that works with any
Xamarin.Forms, Android, iOS, or UWP application that can be accessed from
shared code no matter how the user interface is created.
Text-to-Speech
This enables an application to utilize the built-in text-to-speech engines to speak back text from the device and also to query available languages that the engine can support.
Coding Part
Steps
- 1: Creating new Xamarin.Forms Projects
- 2: Implementation of Text to Speech in Xamarin Forms
Step 1: Creating new Xamarin.Forms Projects
Create New Project by selecting "New Project" Ă "Xamarin Cross Platform App" and Clicking "OK". Note: Xamarin.Forms version should be greater than 5.0.
Then Select Android and iOS Platforms as shown below with Code Sharing Strategy as PCL or .Net Standard and Click OK.
Step 2: Implementation of Text to Speech in Xamarin Forms
In this step, we will see how to implement the functionality in Xamarin.Forms.
Platform Specific Changes:
- If your project's Target Android version is set to Android 11 (R API 30) you must update your Android Manifest with queries that are used with the new package visibility requirements.
- Open the AndroidManifest.xml file under the Properties folder and add the following inside of the manifest node:
Xamarin Forms App Changes:
- Add a reference to Xamarin.Essentials in your class:
- Text-to-Speech works by calling the SpeakAsync method with text and optional parameters, and returns after the utterance has finished.
- This API provide more options on how the audio is spoken back with SpeechOptions that allows setting the volume, pitch, and locale.
0 comments:
Please Comment about the Posts and Blog