C # convert text into sound,

Source: Internet
Author: User

C # convert text into sound,

In the System. Speech namespace, The SpeechSynthesizer class can read the text and play it together ~~

First, introduce System. Speech in the Windows Forms project. Interface section:

 

The background code is also very simple, but some methods of the SpeechSynthesizer class are called:

using System.Windows.Forms;
using System.Speech;
using System.Speech.Synthesis;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private SpeechSynthesizer ss;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            ss = new SpeechSynthesizer();
        }
        private void buttonRead_Click(object sender, EventArgs e)
        {
            ss.Rate = trackBarSpeed.Value;
            ss.Volume = trackBarVolumn.Value;
            ss.SpeakAsync(txtMsg.Text);
        }
        private void buttonPause_Click(object sender, EventArgs e)
        {
            ss.Pause();
        }
        private void buttonContinue_Click(object sender, EventArgs e)
        {
            ss.Resume();
        }
        private void buttonRecord_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer ss = new SpeechSynthesizer();
            ss.Rate = trackBarSpeed.Value;
            ss.Volume = trackBarVolumn.Value;
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Filter = "Wave Files|*.wav";
            ss.SetOutputToWaveFile(sfd.FileName);
            ss.Speak(txtMsg.Text);
            ss.SetOutputToDefaultAudioDevice();
MessageBox. Show ("complete recording ~~ "," Prompt ");
        }
        private void buttonClose_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}

& In C Language

& Can be used as the bitwise AND or address fetch Operator
The following describes two usage methods:
1. bitwise and operation bitwise AND operator "&" are binary operators. Its function is the binary phase corresponding to the two numbers involved in the operation. The result bit is 1 only when the two binary numbers are 1. Otherwise, the result bit is 0. The number of involved operations is supplemented.
For example, 9 & 5 can be written as follows: 00001001 (Binary complement of 9) & 00000101 (Binary complement of 5) 00000001 (Binary complement of 1) Visible 9 & 5 = 1.
Bitwise AND operations are usually used to clear some bits or retain some bits. For example, if a clears the high eight bits of 0 and retains the low eight bits, it can be used as a & 255 operation (255 of the binary number is 0000000011111111 ).
2. Get the address
& As The unary operator, the result is the address of the right operation object.
For example, & x returns the address of x.
The address itself is an abstract concept used to indicate the logical location of an object in the memory.

& In C Language

& Can be used as the bitwise AND or address fetch Operator
The following describes two usage methods:
1. bitwise and operation bitwise AND operator "&" are binary operators. Its function is the binary phase corresponding to the two numbers involved in the operation. The result bit is 1 only when the two binary numbers are 1. Otherwise, the result bit is 0. The number of involved operations is supplemented.
For example, 9 & 5 can be written as follows: 00001001 (Binary complement of 9) & 00000101 (Binary complement of 5) 00000001 (Binary complement of 1) Visible 9 & 5 = 1.
Bitwise AND operations are usually used to clear some bits or retain some bits. For example, if a clears the high eight bits of 0 and retains the low eight bits, it can be used as a & 255 operation (255 of the binary number is 0000000011111111 ).
2. Get the address
& As The unary operator, the result is the address of the right operation object.
For example, & x returns the address of x.
The address itself is an abstract concept used to indicate the logical location of an object in the memory.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.