• (2 Pages)
  • +
  • 1
  • 2

Making your computer talk Rate Topic: ***** 2 Votes

#1 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Posted 29 September 2010 - 07:20 AM

Requirements


Getting Started
> Firstly open up the Visual Basic 2008 Express Edition after installing it...
> Open the file menu and select create new project...
> Set the name property of the form to Form1 if it is not already set
> On the Form1 that appears add one Textbox and set its Name property to InputBox
> Below the textbox add a button and change its name property to TalkButton also change its text property to Talk


Adding the Reference
> Open the 'Project' menu and select 'Add Reference'
> In the window that opens, select the 'COM' tab from top and select 'Microsoft Speech Object Library' (as shown in picture) and click Ok.
Posted Image

The Code
> Right Click on the form and select View Code
> At the very top of the code page add the following code to import the Speech Library
  Imports SpeechLib

> Go back to the form and double click the Button that we put earlier and therefore creating the sub for when it is clicked..
> Inside of the newly created sub add the following code..
        Dim ad As New SpVoice
        ad.Speak(InputBox.Text)


Now save the Project and Run it by selecting the Green Right Pointing arrow in the toolbar on the top or by Selecting Start Debugging from the Debug menu at top..

Enter some text into the Textbox on your form and press the talk button, and your computer should say what you had written..

Is This A Good Question/Topic? 4
  • +

Replies To: Making your computer talk

#2 benbarian  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 04-March 10

Posted 11 October 2010 - 07:05 AM

Thanks a million! Works like a charm!
Was This Post Helpful? 0
  • +
  • -

#3 Gradientpixel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 11-October 10

Posted 12 October 2010 - 12:01 AM

This is a very easy and simple thing to do. Once the program is made it is fun to play around with and I am starting to come up variations on this.
Was This Post Helpful? 0
  • +
  • -

#4 mohdsaifhussain  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-October 10

Posted 15 October 2010 - 12:34 PM


thanx raeali thanx i got it now btw
can any one help me out?

how can i use dis thing on ma system!!
I MEAN like can i use it in ma daily use?
Was This Post Helpful? 0
  • +
  • -

#5 Tryparse  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 80
  • View blog
  • Posts: 193
  • Joined: 20-April 10

Posted 28 October 2010 - 09:03 PM

Is there any way to change the voice? Because I seriously want Stephen Hawking's computer voice ;)
Was This Post Helpful? 0
  • +
  • -

#6 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 06 November 2010 - 10:29 AM

Of the 6 files listed on the page you have linked too, which do I download and install?
Was This Post Helpful? 0
  • +
  • -

#7 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 07 November 2010 - 04:05 AM

I downloaded and installed SpeechSDK51.exe 68MB then followed your tutorial exactly, but I get an error message every time I click my button! :helpsmilie:

The error I get is:

Quote

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Say it.exe

Was This Post Helpful? 0
  • +
  • -

#8 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Posted 07 November 2010 - 04:12 AM

There should be some additional details with the error.. could you post them???
Was This Post Helpful? 0
  • +
  • -

#9 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 07 November 2010 - 04:19 AM

View PostbiggerB, on 07 November 2010 - 03:12 AM, said:

There should be some additional details with the error.. could you post them???

This is the link VS 2010 gave me, along with this:

Quote

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147221164
Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Source=Say it
StackTrace:
at SpeechLib.ISpeechVoice.Speak(String Text, SpeechVoiceSpeakFlags Flags)
at Say_it.Form1.TalkButton_Click(Object sender, EventArgs e) in C:\Users\Sam\AppData\Local\Temporary Projects\Say it\Form1.vb:line 6
at System.Windows.Forms.Control.onclick(EventArgs e)
at System.Windows.Forms.Button.onclick(EventArgs e)
at System.Windows.Forms.Button.onmouseup(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at Say_it.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Was This Post Helpful? 0
  • +
  • -

#10 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 07 November 2010 - 04:56 AM

OK, It works now, I have absolutely no idea why, but it does! :smartass:

Thank you very much for your excellent tutorial.

Just out of interest how would I ensure that it would also work for a user on another computer running windows? :huh:
Was This Post Helpful? 0
  • +
  • -

#11 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 07 November 2010 - 04:27 PM

View PostRetardedGenius, on 07 November 2010 - 03:56 AM, said:

OK, It works now, I have absolutely no idea why, but it does! :smartass:

Thank you very much for your excellent tutorial.

Just out of interest how would I ensure that it would also work for a user on another computer running windows? :huh:


Also, is there anyway I can stop it from freezing the form when it's reading text? :huh:
Was This Post Helpful? 0
  • +
  • -

#12 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Posted 08 November 2010 - 03:10 AM

Well as long as there is the Speech Api and the required framework on the target computer then it should run perfectly..
The freezing happens due to the declaration of the spVoice variable, it loads quite a bit of data into the memory... so if memory is not your concern you could declare the Dim ad As New SpVoice as a higher level public variable.. That way it would only load it once when the program is starting and never again in the program...
Was This Post Helpful? 1
  • +
  • -

#13 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 08 November 2010 - 03:38 PM

View PostbiggerB, on 08 November 2010 - 02:10 AM, said:

Well as long as there is the Speech Api and the required framework on the target computer then it should run perfectly..
The freezing happens due to the declaration of the spVoice variable, it loads quite a bit of data into the memory... so if memory is not your concern you could declare the Dim ad As New SpVoice as a higher level public variable.. That way it would only load it once when the program is starting and never again in the program...

I did that, but it still freezes the window, oddly it only freezes the form itself, the rest of my computer is still fully operational. PS: I've got 4GB of RAM so I wouldn't have thought that would be a problem? :huh:
Was This Post Helpful? 0
  • +
  • -

#14 biggerB  Icon User is offline

  • If at first you donít succeed, call it version 1.0
  • member icon

Reputation: 80
  • View blog
  • Posts: 760
  • Joined: 11-June 10

Posted 08 November 2010 - 04:02 PM

Hmm.. seems to be working for me.. It only takes longer to start the program and afterward it does not hang.. Maybe you have an unrelated problem..
Was This Post Helpful? 0
  • +
  • -

#15 RetardedGenius  Icon User is offline

  • >>──(Knee)──►
  • member icon

Reputation: 125
  • View blog
  • Posts: 555
  • Joined: 30-October 10

Posted 08 November 2010 - 04:30 PM

View PostbiggerB, on 08 November 2010 - 03:02 PM, said:

Hmm.. seems to be working for me.. It only takes longer to start the program and afterward it does not hang.. Maybe you have an unrelated problem..

What kind of problem? I've only had this laptop for a few days lol, it's as good as new!
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2