/// <summary> /// Get all installed and valid languages /// </summary> /// <returns></returns> public IEnumerable <CrossLocale> GetInstalledLanguages() { return(AVSpeechSynthesisVoice.GetSpeechVoices() .OrderBy(a => a.Language) .Select(a => new CrossLocale { Language = a.Language, DisplayName = a.Language })); }
public void Static() { Assert.NotNull(AVSpeechSynthesisVoice.CurrentLanguageCode, "CurrentLanguageCode"); foreach (var ssv in AVSpeechSynthesisVoice.GetSpeechVoices()) { Assert.NotNull(ssv.Language, ssv.Language); } }
public void GetVoices() { // ----------------------------------------------------- foreach (AVSpeechSynthesisVoice v in AVSpeechSynthesisVoice.GetSpeechVoices()) { Debug.WriteLine(v.Name + ", " + v.Language + ", " + v.Identifier); } }
static IEnumerable <Language> FindInstalledLanguages() { return(AVSpeechSynthesisVoice.GetSpeechVoices() .OrderBy(a => a.Language) .Select(a => new Language { Id = a.Language.ToLower(), Name = a.Language })); }
public IEnumerable <string> GetInstalledLanguages() { /* * AVSpeechSynthesisVoice[] locale = AVSpeechSynthesisVoice.GetSpeechVoices(); * foreach (AVSpeechSynthesisVoice loc in locale) * { * } */ return(AVSpeechSynthesisVoice.GetSpeechVoices().Select(a => a.Language).Distinct()); }
public AVSpeechSynthesisVoice GetVoiceByName(string name) { // ----------------------------------------------------- foreach (AVSpeechSynthesisVoice v in AVSpeechSynthesisVoice.GetSpeechVoices()) { if (v.Name.Contains(name)) { return(v); //E.g., There is 'Samantha (Enhanced)' } } return(null); }
public void Static() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Inconclusive("Requires iOS 7.0+"); } Assert.NotNull(AVSpeechSynthesisVoice.CurrentLanguageCode, "CurrentLanguageCode"); foreach (var ssv in AVSpeechSynthesisVoice.GetSpeechVoices()) { Assert.NotNull(ssv.Language, ssv.Language); } }
/// <summary> /// Pronounces the provided text /// </summary> public bool Pronounce(string textToPronounce, string voiceName, double?rateMult, double?pitchMult) { try { var speechUtterance = new AVSpeechUtterance(textToPronounce); // pick the voice Voice voice = null; if (string.IsNullOrEmpty(voiceName) == false) { voice = GetVoices().Where(i => i.FullName == voiceName).FirstOrDefault(); } if (voice != null) { var voices = AVSpeechSynthesisVoice.GetSpeechVoices().ToList(); var voiceObj = voices.Where(i => i.Language == voice.Language).FirstOrDefault(); speechUtterance.Voice = voiceObj; } // rate double rate = rateMult != null ? rateMult.Value : UserPreferences.DefaultVoiceRate; if (Config.IsIOS && Config.OSVersionMajor < 9) { rate *= 0.3; } // configure speechUtterance.Volume = 1.0f; speechUtterance.Rate = (float)rate; speechUtterance.PitchMultiplier = (float)(pitchMult != null ? pitchMult.Value : UserPreferences.DefaultVoicePitch); // pronounce var speechSynthesizer = new AVSpeechSynthesizer(); speechSynthesizer.SpeakUtterance(speechUtterance); return(true); } catch (Exception) { return(false); } }
AVSpeechSynthesisVoice SelectVoice() { AVSpeechSynthesisVoice[] voices = AVSpeechSynthesisVoice.GetSpeechVoices(); AVSpeechSynthesisVoice voice = null; foreach (AVSpeechSynthesisVoice cVoice in voices) { if (cVoice.Language == "en-US") { if (string.Compare(cVoice.Name, "Samantha (Enhanced)", StringComparison.Ordinal) == 0) { voice = cVoice; } } } if (voice == null) { voice = AVSpeechSynthesisVoice.FromLanguage("en-US"); } return(voice); }
public override void Speak(string text, bool gender, int pitch) { var speechSynthesizer = new AVSpeechSynthesizer(); var voci = AVSpeechSynthesisVoice.GetSpeechVoices(); var choices = voci.Where(x => x.Description.Contains(gender ? "female" : "male")); //prefer us AVSpeechSynthesisVoice voice; voice = choices.FirstOrDefault(x => x.Language.ToLowerInvariant().Contains("en-gb")); if (voice == null) { voice = choices.FirstOrDefault(x => x.Language.ToLowerInvariant().Contains("en-gb")); } if (voice == null && voci.Length > 0) { voice = voci[0]; } if (voice == null) { return; } var speechUtterance = new AVSpeechUtterance(text) { Rate = AVSpeechUtterance.DefaultSpeechRate, Voice = voice, Volume = 0.5f, PitchMultiplier = pitch / 100f }; speechSynthesizer.SpeakUtterance(speechUtterance); speechSynthesizer.DidFinishSpeechUtterance += (sender, e) => { speechSynthesizer.Dispose(); }; }
/// <summary> /// Returns a list of available voices /// </summary> public List <Voice> GetVoices() { try { var voiceObjs = AVSpeechSynthesisVoice.GetSpeechVoices(); List <Voice> voices = new List <Voice>(); foreach (var voiceObj in voiceObjs) { voices.Add(new Voice() { Language = voiceObj.Language, Name = "Default iOS" }); } voices = voices.OrderBy(i => i.Language).ToList(); return(voices); } catch (Exception) { return(null); } }
public IEnumerable <string> GetInstalledLanguages() { return(AVSpeechSynthesisVoice.GetSpeechVoices().Select(a => a.Language).Distinct()); }
/// <summary> /// Get all installed and valid languages /// </summary> /// <returns></returns> public Task <IEnumerable <CrossLocale> > GetInstalledLanguages() => Task.FromResult(AVSpeechSynthesisVoice.GetSpeechVoices() .OrderBy(a => a.Language) .Select(a => new CrossLocale { Language = a.Language, DisplayName = a.Language }));
internal static Task <IEnumerable <Locale> > PlatformGetLocalesAsync() => Task.FromResult(AVSpeechSynthesisVoice.GetSpeechVoices() .Select(v => new Locale(v.Language, null, v.Language, v.Identifier)));
public IList <Language> GetLanguages() => _availableLanguages ?? (_availableLanguages = AVSpeechSynthesisVoice.GetSpeechVoices().Select(v => new Language { Id = v.Identifier, Locale = v.Language, FriendlyName = v.Language }).ToList());
public AVSpeechSynthesisVoice[] GetVoices() { return(AVSpeechSynthesisVoice.GetSpeechVoices()); }