Created
November 22, 2018 18:30
-
-
Save icebeam7/66a2b031fefd665916e4f5fc3df96acc to your computer and use it in GitHub Desktop.
DemoTTS: TextToSpeechAndroid.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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