Text conversion to Speech vb.net implementation

Source: Internet
Author: User

imports system.speech.synthesisimports speechlibpublic class form1     Public sub new ()          '   This call is  Windows  Required by the form designer.         initializecomponent ()           '   Add any initialization after  initializecomponent ()   call.     End Sub     ' implement     DIM SS in two different ways  As SpeechSynthesizer  ' defines a speech engine to access global variables     Dim voice As  spvoice = new spvoice  ' Call the third-party tool library speechlib    private sub  Form1_Load (Sender as object, e as eventargs)  Handles MyBase.Load         ss = new speechsynthesizer ()   ' instantiation          dim voicestring as string =  ""   "defines a string         For Each iv As  Installedvoice in ss. Getinstalledvoices ()   ' traverse the installed speech engine              COMBOXVOICE.ITEMS.ADD (Iv. Voiceinfo.name)   ' add its name to the combo box         Next         ComboxVoice.SelectedIndex = 0  ' show first     End  by default Sub    private sub buttonread_click (Sender as object, e as  eventargs)  handles buttonread.click        voice. Voice = voice. Getvoices (String.empty, string.empty). Item (0)   ' Set up Chinese speech          ' voice. Voice = voice. Getvoices (String.empty, string.empty). Item (1)   ' Set English voice, read-only English          '  voice.rate = trackbarspeed.value  ' Set speech speed          ' voice. volume = trackbarvolumn.value  ' Set the volume         ss. Selectvoice (comboxvoice.selecteditem)   ' Select Speech engine         ss. rate = trackbarspeed.value  ' Set the speed         ss. volume = trackbarvolumn.value  ' Set volume          ' Voice. Speak (txtmsg.text, speechvoicespeakflags.svsfdefault)   ' Synchronous reading           '  voice. Speak (Txtmsg.text, speechvoicespeakflags.svsflagsasync)   ' Asynchronous reading          ss. Speakasync (Txtmsg.text)   ' Asynchronous voice     End Sub    Private  Sub buttonpause_click (Sender as object, e as eventargs)  Handles  buttonpause.click         ss. Pause ()   suspend play          voice. Pause ()     end sub    private sub buttoncontinue_click ( Sender as object, e as eventargs)  Handles ButtonContinue.Click         ss. Resume ()   ' Continue playing          ' voice. Resume ()     end sub    private sub buttonrecord_click ( Sender as object, e as eventargs)  Handles ButtonRecord.Click         Dim ss As SpeechSynthesizer = New  SpeechSynthesizer ()   ' defines a local variable         SS. Rate = trackbarspeed.value        ss. Volume = trackbarvolumn.value    &nbsP;   dim sfd as savefiledialog = new savefiledialog ()   ' Defines a file Save prompt box, and instantiates         SFD. filter =  "Wave files|*.wav"   "settings file type is voice file (. wav)          IF SFD. showdialog = dialogresult.ok then  ' If the file name is selected              ss. Setoutputtowavefile (SFD). FileName)   ' output audio file             SS. Speak (Txtmsg.text)             ss. Setoutputtodefaultaudiodevice ()              MessageBox.Show ("Complete recording ~ ~",  "Tips")         End If     end sub    private sub buttonclose_click (sender As  Object, e as evEntargs)  handles buttonclose.click        application.exit ()   ' app exit     end subend class


This article is from the "King Breeze" blog, please be sure to keep this source http://10882708.blog.51cto.com/10872708/1890438

Text conversion to Speech vb.net implementation

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.