Exemple #1
0
        private void GatherVoices()
        {
            Voices = new List <string>();

            string enumVoice = LoquendoX.EnumFirstVoice("");

            while (enumVoice != "")
            {
                Voices.Add(enumVoice);
                enumVoice = LoquendoX.EnumNextVoice();
                //string lan = LoquendoX.GuessLanguage(enumVoice);
                //lan = LoquendoX.GuessFileLanguage(enumVoice);
            }
        }
Exemple #2
0
        private bool IsLoquendoVoice(string voice)
        {
            if (Voices == null)
            {
                Voices = new List <string>();
            }
            bool retVal = false;

            string enumVoice = LoquendoX.EnumFirstVoice("");

            while (enumVoice != "")
            {
                if (enumVoice.ToLower() == voice.ToLower())
                {
                    retVal = true;
                    break;
                }

                enumVoice = LoquendoX.EnumNextVoice();
            }
            return(retVal);
        }
Exemple #3
0
        internal string Speak(string phrase, string volume, string rate, string voice)
        {
            string retVal = string.Empty;

            //System.Diagnostics.Debugger.Break();

            try
            {
                //System.Diagnostics.Debugger.Break();
                if (rate == string.Empty)
                {
                    rate = "50";
                }

                if (voice != string.Empty && Voices.Find(v => v == voice) == null)
                {
                    if (phrase.Contains("\\"))
                    {
                        phrase = GetParsedPhrase(phrase, PhraseFor.Other);
                    }
                    retVal = phrase;
                }
                else
                {
                    if (volume == "")
                    {
                        //LoquendoX.Volume = jarvisWPF.PublicClass.SpeechSynth.VoiceConfigs.Get(Voice).VoiceVolume;
//#if LINKSEXISTS
                        try
                        {
                            volume = "20";
                        }
                        catch
                        {
                            Console.WriteLine("Can't get volume from LINKS...");
                        }
//#endif
                    }
                    else
                    {
                        //LoquendoX.Volume = int.Parse(volume);
                    }
                    //LoquendoX.Speed = int.Parse(rate);

                    phrase = phrase.Replace("\\\\", "\\");

                    //if (voice != "USE FIRST VOICE")

                    if (phrase.StartsWith(@"\language", StringComparison.OrdinalIgnoreCase))
                    {
                        LoquendoX.Read(string.Format(@"\voice={0} \volume={2} \speed={3} {1}", voice, phrase, volume, rate));
                    }
                    else
                    {
                        string lang = null;
//#if LINKSEXISTS
                        try
                        {
                            if (jarvisWPF.PublicClass.SpeechSynth != null)
                            {
                                try
                                {
                                    lang = jarvisWPF.PublicClass.SpeechSynth.VoiceConfigs.Get(Voice).VoiceLanguage;
                                }
                                catch { }
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Can't get language from LINKS...");
                            //System.Diagnostics.Debugger.Break();
                        }
                        //#endif


                        LoquendoX.ReadFile("c:\\temp\\test.txt");
                        LoquendoX.Read(string.Format(@"\language={4} \voice={0} \volume={2} \speed={3} {1}", voice, phrase, volume, rate, lang == null ? "": lang));
                    }
                }
                //Task.WaitAll();
            }
            catch
            {
                if (phrase.Contains("\\"))
                {
                    phrase = GetParsedPhrase(phrase, PhraseFor.Other);
                }

                retVal = phrase;
            }

            return(retVal);
        }