Skip to content

Instantly share code, notes, and snippets.

@icebeam7
Created November 22, 2018 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icebeam7/3e579bb4e8644163d978e9150ccf1660 to your computer and use it in GitHub Desktop.
Save icebeam7/3e579bb4e8644163d978e9150ccf1660 to your computer and use it in GitHub Desktop.
DemoTTS: TextToSpeechiOS.cs
using AVFoundation;
using Xamarin.Forms;
using DemoTTS.iOS.Clases;
using DemoTTS.Interfaces;
[assembly: Dependency(typeof(TextToSpeechiOS))]
namespace DemoTTS.iOS.Clases
{
public class TextToSpeechiOS : ITextToSpeech
{
public void Speak(string text)
{
var speechSynthesizer = new AVSpeechSynthesizer();
var speechUtterance = new AVSpeechUtterance(text)
{
Rate = AVSpeechUtterance.MaximumSpeechRate / 4,
Voice = AVSpeechSynthesisVoice.FromLanguage("en-US"),
Volume = 0.5f,
PitchMultiplier = 1.0f
};
speechSynthesizer.SpeakUtterance(speechUtterance);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment