예제 #1
0
        public static void Speak(string message, VoiceGender voiceGender)
        {
            synth.SelectVoiceByHints(voiceGender);
            string memAvailableVocalMessage = message;

            synth.Speak(memAvailableVocalMessage);
        }
예제 #2
0
        public static void setupVoices()
        {
            ModConfig config = Helper.ReadConfig <ModConfig>();

            currentCulture = CultureInfo.CreateSpecificCulture(config.lang);
            culturelang    = config.lang.Split('-')[0];
            voices         = new Dictionary <string, SpeechProfile>();

            foreach (SpeechConfig npc in config.voices)
            {
                VoiceGender gender = (npc.gender == 0) ? VoiceGender.Male : VoiceGender.Female;

                VoiceAge age = VoiceAge.NotSet;

                if (npc.age == 3)
                {
                    age = VoiceAge.Senior;
                }
                else if (npc.age == 0)
                {
                    age = VoiceAge.Adult;
                }
                else if (npc.age == 1)
                {
                    age = VoiceAge.Teen;
                }
                else if (npc.age == 2)
                {
                    age = VoiceAge.Child;
                }

                voices.Add(npc.name, new SpeechProfile(npc.voicename, gender, age, 0, currentCulture));
            }
        }
예제 #3
0
 /// <summary>
 /// Speaks with a selected voice, message and speech rate
 /// </summary>
 /// <param name="message"></param>
 /// <param name="voice_gender"></param>
 /// <param name="rate"></param>
 public static void Talk(string message, VoiceGender voice_gender, int rate)
 {
     int old_rate = synth.Rate;
     synth.Rate = rate;
     Talk(message, voice_gender);
     synth.Rate = old_rate;
 }
예제 #4
0
        public void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture)
        {
            Helpers.ThrowIfNull(culture, nameof(culture));

            if (voiceAlternate < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(voiceAlternate), SR.Get(SRID.PromptBuilderInvalidVariant));
            }
            if (!VoiceInfo.ValidateGender(gender))
            {
                throw new ArgumentException(SR.Get(SRID.EnumInvalid, "VoiceGender"), nameof(gender));
            }

            if (!VoiceInfo.ValidateAge(age))
            {
                throw new ArgumentException(SR.Get(SRID.EnumInvalid, "VoiceAge"), nameof(age));
            }

            TTSVoice ttsVoice = VoiceSynthesizer.GetEngine(null, culture, gender, age, voiceAlternate, true);

            if (ttsVoice == null)
            {
                // No match - throw
                throw new InvalidOperationException(SR.Get(SRID.SynthesizerSetVoiceNoMatch));
            }
            VoiceSynthesizer.Voice = ttsVoice;
        }
예제 #5
0
 //A function that takes in a message and a selected voice
 public static void Justin_Speak(String message, VoiceGender voiceGender)
 {
     //Change voice back to male
     synth.SelectVoiceByHints(voiceGender);
     //Actually speaks the current CPU Load
     synth.Speak(message);
 }
예제 #6
0
        // Speaks with a gender voice and rate
        public static void Speak(string message, VoiceGender voiceGender, int rate)
        {
            synth.Rate = rate;
            string memAvailableVocalMessage = message;

            synth.Speak(memAvailableVocalMessage);
        }
예제 #7
0
        private static void ReadSettingLine(int i, string[] lines)
        {
            if (i < lines.Length)
            {
                switch (i)
                {
                case 0: ascending = bool.Parse(lines[i]); break;

                case 1: icoordEnabled = bool.Parse(lines[i]); break;

                case 2: enableReadback = bool.Parse(lines[i]); break;

                case 3: autoPlay = bool.Parse(lines[i]); break;

                case 4: boardSize = int.Parse(lines[i]); break;

                case 5: computervoice = (VoiceGender)Enum.Parse(typeof(VoiceGender), lines[i]); break;

                case 6: topLeft.X = double.Parse(lines[i]); break;

                case 7: topLeft.Y = double.Parse(lines[i]); break;

                case 8: bottomRight.X = double.Parse(lines[i]); break;

                case 9: bottomRight.Y = double.Parse(lines[i]); break;

                case 10: enableHotkeys = bool.Parse(lines[i]); break;

                case 11: enableOpponentColorRead = bool.Parse(lines[i]); break;
                    //case 12: enableExcitedVoice = bool.Parse(lines[i]); break;
                }
            }
        }
예제 #8
0
        private void SpeechSave(string Text, decimal Rate, decimal Volume, string SaveLocation, string Language, string Gender)
        {
            string      exceptedLanguage = string.Empty;
            VoiceGender exceptedGender   = VoiceGender.Male;

            switch (Language)
            {
            case ("0"):
                exceptedLanguage = "fr-FR";
                break;

            case ("1"):
                exceptedLanguage = "en-US";
                break;

            case ("2"):
                exceptedLanguage = "ja-JP";
                break;
            }
            switch (Gender)
            {
            case ("0"):
                exceptedGender = VoiceGender.Male;
                break;

            case ("1"):
                exceptedGender = VoiceGender.Female;
                break;
            }
            speaker.Rate = Decimal.ToInt32(Rate);
            speaker.SelectVoiceByHints(exceptedGender, VoiceAge.NotSet, 0, new CultureInfo(exceptedLanguage));
            speaker.Volume = Decimal.ToInt32(Volume);
            speaker.SetOutputToWaveFile(SaveLocation);
            speaker.Speak(Text);
        }
예제 #9
0
 public object ProcessVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant, bool fNewCulture, List <SsmlXmlAttribute> extraNamespace)
 {
     _writer.WriteStartElement("voice");
     if (!string.IsNullOrEmpty(name))
     {
         _writer.WriteAttributeString("name", name);
     }
     if (fNewCulture && culture != null)
     {
         _writer.WriteAttributeString("xml", "lang", null, culture.Name);
     }
     if (gender != 0)
     {
         _writer.WriteAttributeString("gender", gender.ToString().ToLowerInvariant());
     }
     if (age != 0)
     {
         XmlTextWriter writer = _writer;
         int           num    = (int)age;
         writer.WriteAttributeString("age", num.ToString(CultureInfo.InvariantCulture));
     }
     if (variant > 0)
     {
         _writer.WriteAttributeString("variant", variant.ToString(CultureInfo.InvariantCulture));
     }
     if (extraNamespace != null)
     {
         foreach (SsmlXmlAttribute item in extraNamespace)
         {
             _writer.WriteAttributeString("xmlns", item._name, item._ns, item._value);
         }
     }
     return(null);
 }
예제 #10
0
        public object ProcessVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant, bool fNewCulture, List <SsmlXmlAttribute> extraNamespace)
        {
            _writer.WriteStartElement("voice");
            if (!string.IsNullOrEmpty(name))
            {
                _writer.WriteAttributeString("name", name);
            }
            if (fNewCulture && culture != null)
            {
                _writer.WriteAttributeString("xml", "lang", null, culture.Name);
            }
            if (gender != VoiceGender.NotSet)
            {
                _writer.WriteAttributeString("gender", gender.ToString().ToLowerInvariant());
            }
            if (age != VoiceAge.NotSet)
            {
                _writer.WriteAttributeString("age", ((int)age).ToString(CultureInfo.InvariantCulture));
            }
            if (variant > 0)
            {
                _writer.WriteAttributeString("variant", (variant).ToString(CultureInfo.InvariantCulture));
            }

            // write all the additional namespace
            if (extraNamespace != null)
            {
                foreach (SsmlXmlAttribute ns in extraNamespace)
                {
                    _writer.WriteAttributeString("xmlns", ns._name, ns._ns, ns._value);
                }
            }
            return(null);
        }
예제 #11
0
 public L2FVoice(string name, VoiceGender gender, VoiceAge age, string culture, L2FSpeechEngine engine) : base(engine)
 {
     Name    = name;
     Gender  = gender;
     Age     = age;
     Culture = culture;
 }
예제 #12
0
 /// <summary>
 /// configures the current voice
 /// </summary>
 /// <param name="voiceGender">the voice gender</param>
 /// <param name="cultureInfo">the culture info</param>
 public void SetVoice(VoiceGender voiceGender, CultureInfo cultureInfo)
 {
     _speaker.SetOutputToDefaultAudioDevice();
     _speaker.SelectVoiceByHints(voiceGender, VoiceAge.NotSet, 0, cultureInfo);
     _speaker.Rate   = 1;
     _speaker.Volume = 100;
 }
예제 #13
0
 public void StartSpeech(string text, bool value, VoiceGender type)
 {
     if (value == true)
     {
         PromptBuilder promptBuilder = new PromptBuilder();
         PromptStyle   promptStyle   = new PromptStyle();
         promptStyle.Volume   = PromptVolume.Soft;
         promptStyle.Rate     = PromptRate.Slow;
         promptStyle.Emphasis = PromptEmphasis.Moderate;
         promptBuilder.StartStyle(promptStyle);
         promptBuilder.EndStyle();
         promptBuilder.AppendTextWithHint(text, SayAs.SpellOut);
         SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
         speechSynthesizer.SelectVoiceByHints(type);
         speechSynthesizer.Speak(promptBuilder);
     }
     else
     {
         PromptBuilder promptBuilder = new PromptBuilder();
         PromptStyle   promptStyle   = new PromptStyle();
         promptStyle.Volume   = PromptVolume.Soft;
         promptStyle.Rate     = PromptRate.Slow;
         promptStyle.Emphasis = PromptEmphasis.Moderate;
         promptBuilder.StartStyle(promptStyle);
         promptBuilder.EndStyle();
         promptBuilder.AppendText(text);
         SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
         speechSynthesizer.SelectVoiceByHints(type);
         speechSynthesizer.Speak(promptBuilder);
     }
 }
예제 #14
0
 internal static bool ValidateGender(VoiceGender gender)
 {
     if (gender != VoiceGender.Female && gender != VoiceGender.Male && gender != VoiceGender.Neutral)
     {
         return(gender == VoiceGender.NotSet);
     }
     return(true);
 }
예제 #15
0
 public WindowsVoice(int rate, VoiceGender gender, VoiceAge age, CultureInfo language)
 {
     Language    = language;
     Synthesizer = new SpeechSynthesizer();
     Synthesizer.SetOutputToDefaultAudioDevice();
     Synthesizer.Rate = 1;
     Synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult, 0, language);
 }
예제 #16
0
 /// <summary>
 /// cTor:
 /// </summary>
 /// <param name="name">Voice Display Name</param>
 /// <param name="lang">Language Code</param>
 /// <param name="desc">Voice Description</param>
 /// <param name="id">Voice ID</param>
 /// <param name="gender"></param>
 public VoiceInfo(string name, string lang, string desc, string id, VoiceGender gender)
 {
     Gender      = gender;
     Name        = name;
     Language    = lang;
     Description = desc;
     Id          = id;
 }
 public SpeechProfile(string name, VoiceGender gender, VoiceAge age, int alternate, CultureInfo culture)
 {
     this.name      = name;
     this.gender    = gender;
     this.age       = age;
     this.alternate = alternate;
     this.culture   = culture;
 }
        // Talk void so that we don't have to copy multiple lines of code for use in multiple cases.
        public static void Talk(string message, VoiceGender voiceGender, int rate)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.SelectVoiceByHints(voiceGender);
            synth.Rate = (rate);
            synth.Speak(message);
        }
예제 #19
0
        private void btnRead_Click(object sender, EventArgs e)
        {
            if (btnRead.Text == "Read")
            {
                if (synth == null)
                {
                    synth = new SpeechSynthesizer();
                }
                VoiceGender gender  = chkIsMale.Checked ? VoiceGender.Male : VoiceGender.Female;
                string      culture = "";
                //if (cboLanguage.Text == "English")
                //    culture = "Microsoft";
                //else
                //    culture = "NHMTTS Voice";
                //synth.SelectVoice(synth.GetInstalledVoices().Where(v => v.VoiceInfo.Name.Contains(culture) && v.VoiceInfo.Gender == gender).First().VoiceInfo.Name);

                if (cboLanguage.Text == "English")
                {
                    culture = "en-US";
                }
                else
                {
                    culture = "vi-VN";
                }

                if (!synth.Voice.Culture.Name.Contains(culture))
                {
                    synth.SelectVoice(synth.GetInstalledVoices().Where(v => v.VoiceInfo.Culture.Name == culture && v.VoiceInfo.Gender == gender).First().VoiceInfo.Name);
                }

                // Configure the audio output.
                outputFile = outputFolder + @"\" + id + "_" + DateTime.Now.ToString().Replace('/', '_').Replace(':', '_') + ".wav";
                synth.SetOutputToWaveFile(outputFile);

                // Register for the SpeakCompleted event.
                synth.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(synth_SpeakCompleted);


                synth.SpeakAsync(txtTitle.Text + rtbContent.Text);
                btnRead.Text = "Stop";
            }
            else
            {
                btnRead.Text = "Read";
                synth.SpeakAsyncCancelAll();
            }
            //SpeechLib. oVoice = new SpeechLib();
            //SpVoice oVoice = new SpVoice();
            //SpFileStream cpFileStream = new SpFileStream();
            //if (cboLanguage.Text == "English")
            //    oVoice.Voice = oVoice.GetVoices().Item(2);
            //else
            //    oVoice.Voice = oVoice.GetVoices().Item(1);
            //oVoice.Volume = 100;
            //oVoice.Rate = 4;//4

            //oVoice.Speak(txtTitle.Text + rtbContent.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
        }
예제 #20
0
 /// <summary>
 /// Selects a voice with specific characteristics.
 /// </summary>
 public void SelectVoiceByHints(VoiceGender gender, VoiceAge age,
                                int voiceAlternate, CultureInfo culture)
 {
     _gender         = gender;
     _age            = age;
     _voiceAlternate = voiceAlternate;
     _culture        = culture;
     SelectVoice();
 }
예제 #21
0
        public static void SetUp(VoiceGender gender, VoiceAge age)
        {
            //Customise the voice

            //speechSyn.SelectVoice("Vocalizer Expressive Samantha Harpo 22kHz");
            speechSyn.SelectVoiceByHints(gender, age, 0);
            speechSyn.SpeakStarted   += SpeechSyn_SpeakStarted;
            speechSyn.SpeakCompleted += SpeechSyn_SpeakCompleted;
        }
예제 #22
0
        public static void Speak(VoiceGender gender, string message)
        {
            Synth.SelectVoiceByHints(gender);

            UseGoogle = false; // Google's Text-To-Speech API is unavailable.

            Thread t = new Thread(() => {
                if (UseGoogle == true)
                {
                    string uri =
                        "http://translate.google.com/translate_tts?tl=en&ie=UTF-8&client=t&q=" +
                        System
                        .Web
                        .HttpUtility
                        .UrlEncode(message)
                        .ToString()
                    ;

                    WebClient client = new WebClient();

                    // Send fake request headers for "authentication".
                    client.Headers["Referer"]    = "http://translate.google.com/";
                    client.Headers["User-Agent"] = "stagefright/1.2 (Linux;Android 5.0)";

                    try {
                        client.DownloadFile(uri, TemporaryFile);

                        SoundPlayer sound = new SoundPlayer(TemporaryFile);

                        sound.Play();

                        File.Delete(TemporaryFile);
                    }
                    catch (Exception ex)
                    {
                        UseGoogle = false;

                        System.Windows.Forms.MessageBox.Show(
                            "Turned off Google Text-to-Speech:" + Environment.NewLine +
                            Environment.NewLine +
                            ex.Message + Environment.NewLine +
                            Environment.NewLine +
                            ex.StackTrace
                            );

                        Synth.Speak(message);
                    }
                }
                else
                {
                    Synth.Speak(message);
                }
            });

            t.Start();
        }
예제 #23
0
 public UserSettings(string username, UserGender usergender, string assistantName = "Tars", VoiceGender voiceGender = VoiceGender.Male, int synthVol = 100, int synthRate = 0)
 {
     Username               = username;
     Gender                 = usergender;
     AssistantName          = assistantName;
     SynthesizerVoiceGender = voiceGender;
     //Movies = moviesFolder;
     SynthesizerVolume = synthVol;
     SynthesizerRate   = synthRate;
 }
예제 #24
0
 internal VoiceInfo(VoiceGender gender, VoiceAge age, int voiceAlternate)
 {
     if (voiceAlternate < 0)
     {
         throw new ArgumentOutOfRangeException("voiceAlternate", SR.Get(SRID.PromptBuilderInvalidVariant));
     }
     _gender  = gender;
     _age     = age;
     _variant = voiceAlternate + 1;
 }
예제 #25
0
 public TextToSpeech(string text, VoiceGender voiceGender, VoiceAge voiceAge, int voicePosition, string culture, int volume, int rate)
 {
     Text          = text;
     VoiceGender   = voiceGender;
     VoiceAge      = voiceAge;
     VoicePosition = voicePosition;
     CultureInfo   = culture;
     Volume        = volume;
     Rate          = rate;
 }
예제 #26
0
        internal void SetVoice(string name, CultureInfo culture, VoiceGender gender, VoiceAge age, int variant)
        {
            TTSVoice ttsVoice = _voiceSynthesis.GetEngine(name, culture, gender, age, variant, false);

            if (!ttsVoice.Equals(_ttsVoice))
            {
                _ttsVoice      = ttsVoice;
                _fNotInTextSeg = true;
            }
        }
예제 #27
0
 /// <summary>
 /// Play a sound using the voice assistant
 /// </summary>
 /// <param name="phrase">What it will say</param>
 /// <param name="gender">What gender</param>
 /// <param name="age">What age</param>
 /// <param name="whichCulture">Which culture to use Ex: en-US,pt-BR and etc</param>
 public static void PlayPhrase(string phrase, VoiceGender gender = VoiceGender.Female,
                               VoiceAge age = VoiceAge.Adult, string whichCulture = "en-US")
 {
     using (var playphrase = new SpeechSynthesizer())
     {
         playphrase.SelectVoiceByHints(gender, age, -2, new CultureInfo(whichCulture));
         playphrase.SetOutputToDefaultAudioDevice();
         playphrase.Speak(phrase);
     }
 }
예제 #28
0
 public TextToSpeech(string text, VoiceGender voiceGender, VoiceAge voiceAge, int voicePosition, string culture, int volume, int rate )
 {
     Text = text;
     VoiceGender = voiceGender;
     VoiceAge = voiceAge;
     VoicePosition = voicePosition;
     CultureInfo = culture;
     Volume = volume;
     Rate = rate;
 }
예제 #29
0
        public static void GetFormants(VoiceGender gender, double height, double backness, double roundedness, ref double f1, ref double f2, ref double f3)
        {
            var vowels = gender == VoiceGender.Child ? _vowelsChild : _vowelsAdult;

            if (_weightBuffer == null)
            {
                _weightBuffer = new double[_vowelsAdult.Length];
            }
            f1 = f2 = f3 = 0.0;
            double distSum   = 0.0;
            double minDist   = -1.0;
            double weightSum = 0.0;
            double dist      = 0.0;
            double weight;
            double h, b, r;

            // Calculate the sum of the distances between the input point and all the prism's reference points
            for (int i = 0; i < vowels.Length; i++)
            {
                h = height - vowels[i].Height;
                b = backness - vowels[i].Backness;
                r = roundedness - vowels[i].Roundedness;
                _weightBuffer[i] = dist = Math.Sqrt(h * h + b * b + r * r);
                if (dist <= 0.0)
                {
                    f1 = vowels[i].F1;
                    f2 = vowels[i].F2;
                    f3 = vowels[i].F3;
                    return;
                }
                distSum += dist;
                if (minDist < 0 || dist < minDist)
                {
                    minDist = dist;
                }
            }

            // Calculate secondary weight sum
            // Buffer contains distances
            for (int i = 0; i < vowels.Length; i++)
            {
                dist       = _weightBuffer[i];
                weightSum += _weightBuffer[i] = (1.0 - dist / distSum) / Math.Pow(4.5, dist / minDist);
            }

            // Calculate weights
            // Buffer contains secondary weights
            for (int i = 0; i < vowels.Length; i++)
            {
                weight = _weightBuffer[i] / weightSum;
                f1    += weight * vowels[i].F1;
                f2    += weight * vowels[i].F2;
                f3    += weight * vowels[i].F3;
            }
        }
예제 #30
0
        public static void Speak(String message, VoiceGender gender = VoiceGender.Male, int age = 30)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.SelectVoiceByHints(gender, DetermineAge(age));
            // Configure the audio output.
            synth.SetOutputToDefaultAudioDevice();
            // Speak a string.
            synth.SpeakAsync(message);
        }
예제 #31
0
파일: MeowFile.cs 프로젝트: wrociu/Meow
        public void FeedTheCat(bool bReplaceFile)
        {
            var synth = new SpeechSynthesizer();
            //
            var installedVoices = synth.GetInstalledVoices();

            foreach (var voice in installedVoices)
            {
                string      name    = voice.VoiceInfo.Name;
                VoiceGender gender  = voice.VoiceInfo.Gender;
                var         culture = voice.VoiceInfo.Culture;
                LogOperation("SVoice name: " + name);
                LogOperation("culture: " + culture.ToString());
            }
            synth.SelectVoice("Microsoft Zira Desktop");

            //

            int    timeStampIterator = 1;
            int    totalLinesChanged = 0;
            string meowedFile        = this.fileName + ".meowed";


            Regex rgx = new Regex(this.meowPattern);

            string[]     lines  = System.IO.File.ReadAllLines(this.fileName);
            StreamWriter writer = new StreamWriter(meowedFile);

            LogOperation("Started scanning " + this.fileName);

            synth.SpeakAsync("Started scanning ");

            for (int i = 0; i < lines.Length; i++)
            {
                ApplyLineChanges(ref timeStampIterator, ref totalLinesChanged, rgx, lines, i);

                writer.WriteLine(lines[i]);
            }

            writer.Close();
            LogOperation("Scanning " + this.fileName + " Completed");
            LogOperation(totalLinesChanged.ToString() + " lines changed");
            synth.SpeakAsync(totalLinesChanged.ToString() + " lines changed");

            if (bReplaceFile)
            {
                File.Replace(meowedFile, this.fileName, null);
                LogOperation(this.fileName + " replaced");
            }
            else
            {
                LogOperation(meowedFile + " Created");
            }
        }
예제 #32
0
        public UWPLocalSpeaker(MediaElement Media, VoiceGender G)
        {
            this.Media = Media;
            var v = (from x in SpeechSynthesizer.AllVoices
                     where (x.Gender == G && x.Language == "ru-RU")
                     select x).FirstOrDefault();

            if (v != null)
            {
                Synthesizer.Voice = v;
            }
        }
예제 #33
0
 public void Parse(GameBitBuffer buffer)
 {
     SNOConversation = buffer.ReadInt(32);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadBool();
     LineID = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     Field5 = buffer.ReadInt(32);
     Field6 = buffer.ReadInt(32);
     Gender = (VoiceGender)buffer.ReadInt(32);
     VoiceClassID = buffer.ReadInt(32);
     snoSpeakerActor = buffer.ReadInt(32);
     Name = buffer.ReadCharArray(49);
     Field11 = buffer.ReadInt(32);
     Field12 = buffer.ReadInt(32);
     Field13 = buffer.ReadInt(32);
     Field14 = buffer.ReadInt(32);
     Field15 = buffer.ReadInt(32);
 }
예제 #34
0
 public void Parse(GameBitBuffer buffer)
 {
     SNOConversation = buffer.ReadInt(32);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadBool();
     Field3 = buffer.ReadBool();
     LineID = buffer.ReadInt(32);
     Speaker = buffer.ReadInt(32);
     Field5 = buffer.ReadInt(32);
     TextClass = (Class)buffer.ReadInt(32);
     Gender = (VoiceGender)buffer.ReadInt(32);
     AudioClass = (Class)buffer.ReadInt(32);
     SNOSpeakerActor = buffer.ReadInt(32);
     Name = buffer.ReadCharArray(49);
     Field11 = buffer.ReadInt(32);
     AnimationTag = buffer.ReadInt(32);
     Duration = buffer.ReadInt(32);
     Field14 = buffer.ReadInt(32);
     Field15 = buffer.ReadInt(32);
 }
 public L2FVoice(string name, VoiceGender gender, VoiceAge age, string culture, L2FSpeechEngine engine)
     : base(engine)
 {
     Name = name;
     Gender = gender;
     Age = age;
     Culture = culture;
 }
예제 #36
0
 /// <summary>
 /// Speaks with a selected voice at a selected speed
 /// </summary>
 /// <param name="message"></param>
 /// <param name="voiceGender"></param>
 /// <param name="rate"></param>
 public static void JarvisSpeak(string message, VoiceGender voiceGender, int rate)
 {
     synth.Rate = rate;
     JarvisSpeak(message, voiceGender);
 }
예제 #37
0
        bool IDE = true; //Settings.SettingsJarvis.Default.fastStart;

        #endregion Fields

        #region Methods

        /// <summary>
        /// Speaks with a selected voice
        /// </summary>
        /// <param name="message"></param>
        /// <param name="voiceGender"></param>
        public static void JarvisSpeak(string message, VoiceGender voiceGender)
        {
            synth.SelectVoiceByHints(voiceGender);
            synth.Speak(message);
        }
		private async Task SpeakAsync(string text, VoiceGender gender, bool waitUntilCompleted)
		{
			this.speaker.SetVoice( gender );
			SpeechSynthesisStream stream = await this.speaker.SynthesizeText( text );
			this.mediaElement.SetSource( stream, stream.ContentType );

			if( waitUntilCompleted )
			{
				TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
				this.mediaElement.MediaEnded += ( sender, args ) =>
				{
					tcs.TrySetResult( true );
				};
				this.mediaElement.Play();

				await tcs.Task;
			}
			else
			{
				this.mediaElement.Play();
			}
		}
 private bool ConvertWithSystemSpeech(string FileContent, string voiceName, VoiceGender gender,CultureInfo ci,int rate, string tempfile)
 {
     Console.WriteLine("Converting with: System Speech");
     try
     {
         EncodingFormat eformat = EncodingFormat.Pcm;
         var speech = new SpeechSynthesizer();
         var installedVoices = speech.GetInstalledVoices();
         VoiceInfo selectedVoice = null;
         foreach (var voice in installedVoices)
         {
             if (voice.VoiceInfo.Name == voiceName)
             {
                 selectedVoice = voice.VoiceInfo;
                 break;
             }
             else if (voice.VoiceInfo.Culture == ci)
             {
                 if (voice.VoiceInfo.Gender == gender)
                 {
                     selectedVoice = voice.VoiceInfo;
                     break;
                 }
             }
         }
         speech.SelectVoice(selectedVoice.Name);
         var safi = new SpeechAudioFormatInfo(eformat, 22000, 16, 1, 22000 * 4, 4, null);
         speech.SetOutputToWaveFile(tempfile, safi);
         speech.Speak(FileContent);
         speech.SetOutputToNull();
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return false;
     }
 }
 private bool isVoiceInstalled(CultureInfo ci, VoiceGender gender, string voiceName)
 {
     bool result = false;
     try
     {
         var speech = new SpeechSynthesizer();
         var installedVoices = speech.GetInstalledVoices();
         VoiceInfo selectedVoice = null;
         foreach (var voice in installedVoices)
         {
             if (voice.VoiceInfo.Name == voiceName)
             {
                 result = true;
                 selectedVoice = voice.VoiceInfo;
                 break;
             }
             else if (voice.VoiceInfo.Culture == ci)
             {
                 if (voice.VoiceInfo.Gender == gender)
                 {
                     result = true;
                     selectedVoice = voice.VoiceInfo;
                     break;
                 }
             }
         }
         //comment the below condition to include default Microsoft installed voices
         if (selectedVoice != null)
             if (result && selectedVoice.Name.StartsWith("Microsoft", StringComparison.InvariantCultureIgnoreCase))
             {
                 result = false;
             }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return true;
     }
     return result;
 }
예제 #41
0
 private static void DataStore_VoiceGenderChanged(VoiceGender voiceGender)
 {
     //handler for the VoiceGenderChanged Event
     mainSynthesizer.SelectVoiceByHints(voiceGender);
 }
예제 #42
0
 /// <summary>
 /// Sets the current voice to one based on the <paramref name="gender"/> and <paramref name="age"/>.
 /// </summary>
 /// <param name="gender">The gender of the voice to change to.</param>
 /// <param name="age">The age of the voice.</param>
 public override void SelectVoiceByHints(VoiceGender gender, VoiceAge age)
 {
     this.speechSynthesizer.SelectVoiceByHints(gender, age);
 }
예제 #43
0
 /// <summary>
 /// Sets the current voice to one based on the <paramref name="gender"/>, <paramref name="age"/>, <paramref name="voiceAlternate"/> and <paramref name="culture"/>.
 /// </summary>
 /// <param name="gender">The gender of the voice to change to.</param>
 /// <param name="age">The age of the voice.</param>
 /// <param name="voiceAlternate">The voice alternate.</param>
 /// <param name="culture">The specific culture to select a voice for.</param>
 public override void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture)
 {
     this.speechSynthesizer.SelectVoiceByHints(gender, age, voiceAlternate, culture);
 }
예제 #44
0
 public void SetVoice( VoiceGender gender )
 {
     this.synthesizer.Voice = SpeechSynthesizer.AllVoices.First( v => v.Gender == gender );
 }
예제 #45
0
파일: Speech.cs 프로젝트: ktos/sayanything
 public static IAsyncAction Say(string text, string language, VoiceGender gender)
 {
     var text2speech = new SpeechSynthesizer();
     var ssml = string.Format("<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\"{0}\"><voice gender=\"{1}\">{2}</voice></speak>", language, gender.ToString().ToLower(), text);
     return text2speech.SpeakSsmlAsync(ssml);
 }
예제 #46
0
 /// <summary>
 /// Sets the current voice to one based on the <paramref name="gender"/>, <paramref name="age"/>, <paramref name="voiceAlternate"/> and <paramref name="culture"/>.
 /// </summary>
 /// <param name="gender">The gender of the voice to change to.</param>
 /// <param name="age">The age of the voice.</param>
 /// <param name="voiceAlternate">The voice alternate.</param>
 /// <param name="culture">The specific culture to select a voice for.</param>
 public virtual void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture)
 {
     throw new NotImplementedException();
 }
예제 #47
0
 /// <summary>
 /// Sets the current voice to one based on the <paramref name="gender"/> and <paramref name="age"/>.
 /// </summary>
 /// <param name="gender">The gender of the voice to change to.</param>
 /// <param name="age">The age of the voice.</param>
 public virtual void SelectVoiceByHints(VoiceGender gender, VoiceAge age)
 {
     throw new NotImplementedException();
 }