Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
DemoTTS: TextToSpeechAndroid.cs
using Android.Speech.Tts;
using Xamarin.Forms;
using DemoTTS.Droid.Clases;
using DemoTTS.Interfaces;
[assembly: Dependency(typeof(TextToSpeechAndroid))]
namespace DemoTTS.Droid.Clases
{
public class TextToSpeechAndroid : Java.Lang.Object, ITextToSpeech, TextToSpeech.IOnInitListener
{
TextToSpeech tts;
string message;
public void Speak(string text)
{
message = text;
if (tts == null)
tts = new TextToSpeech(MainActivity.Instance, this);
else
tts.Speak(text, QueueMode.Flush, null, null);
}
public void OnInit(OperationResult status)
{
if (status.Equals(OperationResult.Success))
tts.Speak(message, QueueMode.Flush, null, null);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.