Created
November 22, 2018 18:41
-
-
Save icebeam7/3e579bb4e8644163d978e9150ccf1660 to your computer and use it in GitHub Desktop.
DemoTTS: TextToSpeechiOS.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 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