Esempio n. 1
0
    /*Reproduce sound. First select whitch kind of Option must to reproduce.
     * Second will be reproduced each character in CodeSound.
     */
    public void reproduceSound(object sender, EventArgs e)
    {
        SpeechLib.SpVoiceClass m_TTS = new SpeechLib.SpVoiceClass();
        string codeSound             = "";

        if (_OptionChoose == "0")
        {
            codeSound = _numbers;
        }
        if (_OptionChoose == "1")
        {
            codeSound = _letters;
        }
        if (_OptionChoose == "2")
        {
            codeSound = _fullcode.Substring(0, 1).ToString() + _fullcode.Substring(6, 1).ToString();
        }
        if (_OptionChoose == "3")
        {
            codeSound = _fullcode.Substring(0, 4).ToString();
        }
        if (_OptionChoose == "4")
        {
            codeSound = _fullcode.Substring(4, 3).ToString();
        }
        if (_OptionChoose == "5")
        {
            codeSound = _fullcode;
        }

        for (int i = 0; i < codeSound.Length; i++)
        {
            char   codepart       = codeSound.Substring(i, 1).ToCharArray()[0];
            string UpperLowerCase = "";
            if (Char.IsLetter(codepart))
            {
                if (Char.IsUpper(codepart))
                {
                    UpperLowerCase = "Upper Case";
                }
                else
                {
                    UpperLowerCase = "Lower Case";
                }
                m_TTS.Speak(UpperLowerCase, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
            }
            m_TTS.Speak(codeSound.Substring(i, 1).ToString(), SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync);
            m_TTS.WaitUntilDone(Timeout.Infinite);
            //m_TTS.Speak(codeSound.Substring(i, 1).ToString(), SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
        }
        //Response.Write("");
    }
Esempio n. 2
0
        private void toolStrip3_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            switch (e.ClickedItem.Tag + "")
            {
            case "1":
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    textBox2.Text = File.ReadAllText(openFileDialog1.FileName, Encoding.Default);
                }
                break;

            case "2":
                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(saveFileDialog1.FileName, textBox2.Text, Encoding.Default);
                }
                break;

            case "3":
                if (fontDialog1.ShowDialog() == DialogResult.OK)
                {
                    textBox2.Font = fontDialog1.Font;
                }
                break;

            case "4":
                SpeechLib.SpVoiceClass sp = new SpeechLib.SpVoiceClass();
                sp.Speak(textBox2.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
                break;
            }
        }
Esempio n. 3
0
        public void Play()
        {
            var synth  = new SpeechLib.SpVoiceClass();
            var voices = synth.GetVoices("", $"Gender={VoiceGender};Age={VoiceAge};Language={new CultureInfo(CultureInfo).LCID:X}");

            synth.Voice  = voices.Item(0);
            synth.Volume = Volume;
            synth.Rate   = Rate;
            synth.Speak(Text);
        }
Esempio n. 4
0
        /// <summary>
        /// Speak text into a file.
        /// </summary>
        /// <param name="s">The text to be saved.</param>
        /// <param name="path">The file to save to.</param>
        /// <returns>false if a file write fails, true otherwise.</returns>
        public bool SpeakToFile(string s, string path)
        {
            try
            {
                SpeechLib.SpFileStream  stream = new SpeechLib.SpFileStream();
                SpeechLib.SpAudioFormat format = new SpeechLib.SpAudioFormat();

                format.Type = SpeechLib.SpeechAudioFormatType.SAFT32kHz16BitStereo;

                stream.Format = format;
                stream.Open(path, SpeechLib.SpeechStreamFileMode.SSFMCreateForWrite, false);
                voice.AudioOutputStream = stream;

                voice.Speak(s, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
                stream.Close();
                voice.AudioOutputStream = null;
                return(true);
            } catch (Exception) {
                return(false);
            }
        }