Answered by:
Text to speech exception error

Question
-
I'm working on text to speech for my program and theres an exception that i cannot find solution to.
Wednesday, February 8, 2017 6:19 PM
Answers
-
Hi CakeMonsey,
Thank you for posting here.
Make sure the System.Speech had been added in your project:
1. In the Solution Explorer window, right-click References, and then click Add Reference.
2.In the Add Reference window, on the .NET tab, scroll until you find System.Speech and select it, and then click OK.For more information about gain access to the System.Speech namespaces, you could refer that: https://msdn.microsoft.com/en-us/library/office/hh361618(v=office.14).aspx
And a very easy introduction to Miccrosoft .NET Speech Synthesis: https://www.codeproject.com/Articles/28725/A-Very-Easy-Introduction-to-Microsoft-NET-Speech-S
Hope it will be helpful to you.
Best Regards,
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by CakeMonsey Sunday, February 12, 2017 11:47 AM
Thursday, February 9, 2017 5:50 AM
All replies
-
Did you add reference to System.Speech in Project tab, Add reference, Assemblies, Framework, System.Speech? Or how did you add ref to System.Speech?
If you place Option Strict On at the top of your code window or set Visual Studio to use it for all projects and you provide an imports statement which is not referenced the imports statement will display with an error.
If not referencing System.Speech is the issue this should correct the problem. Otherwise please reply.
Also see Microsoft Speech Platform - Runtime (Version 11) and Microsoft Speech Platform - Software Development Kit (SDK) (Version 11).
La vida loca
- Edited by Mr. Monkeyboy Wednesday, February 8, 2017 6:32 PM
Wednesday, February 8, 2017 6:24 PM -
i had to import Microsoft.Speech.Synthesis because System.Speech.Synthesis was unneccesary as it said. So it should work but it doesn't.Wednesday, February 8, 2017 6:44 PM
-
i had to import Microsoft.Speech.Synthesis because System.Speech.Synthesis was unneccesary as it said. So it should work but it doesn't.
I realize that. Did you add an appropriate reference for speech synthesis as I mentioned in my post? Or did you not understand what I wrote in my post?La vida loca
Wednesday, February 8, 2017 6:59 PM -
For Speech with Microsoft it is important what OS is installed.
It seems as if every one has its own final solution. (Currently we are at Cortana, any association with my name is by coincidence).
The documentation from Microsoft is however made if that does not matter (while it does extremely).
Success
Cor- Edited by Cor Ligthert Wednesday, February 8, 2017 7:21 PM
Wednesday, February 8, 2017 7:20 PM -
i had to import Microsoft.Speech.Synthesis because System.Speech.Synthesis was unneccesary as it said. So it should work but it doesn't.
Never mind. I didn't realize your actual Imports statement was incorrect or where you got it from.
The correct Imports statement is "Imports System.Speech.Synthesis" and then you need to add a reference to it in Project tab, Add reference, Assemblies, Framework, System.Speech.
You should search MSDN when you attempt to use things that you do not know in order to provide appropriate references and such.
Also see SpeechSynthesizer Class.
La vida loca
- Edited by Mr. Monkeyboy Wednesday, February 8, 2017 7:30 PM
Wednesday, February 8, 2017 7:22 PM -
I added a correct reference and i did try "Imports System.Speech.Synthesis" but it said it said that its unnecesary and didn't work at all.
- Edited by CakeMonsey Wednesday, February 8, 2017 7:52 PM
Wednesday, February 8, 2017 7:52 PM -
I added a correct reference and i did try "Imports System.Speech.Synthesis" but it said it said that its unnecesary and didn't work at all.
Did you remove Imports Microsoft.Speech.Synthesis?
It works on my system. And you don't display your code on how you try to use it. It's fine to display pictures but if you have issues with code then place the code in a code block. That way the code can be observed.
La vida loca
- Edited by Mr. Monkeyboy Wednesday, February 8, 2017 8:11 PM
Wednesday, February 8, 2017 7:59 PM -
Create a test project and try it. Works fine on my system.
Maybe you have references for Microsoft.Speech.Synthesis interfering with System.Speech.Synthesis in your project, who knows?
Option Strict On Imports System.Speech.Synthesis ' in Project tab, Add reference, Assemblies, Framework, System.Speech Public Class Form1 Dim Speaker As New SpeechSynthesizer Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - CInt(Screen.PrimaryScreen.WorkingArea.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - CInt(Screen.PrimaryScreen.WorkingArea.Height / 2))) Speaker.SetOutputToDefaultAudioDevice() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Speaker.SpeakAsync("Hello") End Sub End Class
La vida loca
- Edited by Mr. Monkeyboy Wednesday, February 8, 2017 8:11 PM
- Proposed as answer by Neda Zhang Thursday, February 9, 2017 4:37 AM
Wednesday, February 8, 2017 8:08 PM -
Using VS 2015 Community:
Added Reference to System.Speech under Project, References
Code:
Imports Text_Speech Public Class Form1 Dim Spkr As New Speech.Synthesis.SpeechSynthesizer Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Spkr.SpeakAsync(TextBox1.Text) End Sub End Class
Works just fine.- Proposed as answer by Neda Zhang Thursday, February 9, 2017 4:37 AM
Wednesday, February 8, 2017 10:45 PM -
Hi CakeMonsey,
Thank you for posting here.
Make sure the System.Speech had been added in your project:
1. In the Solution Explorer window, right-click References, and then click Add Reference.
2.In the Add Reference window, on the .NET tab, scroll until you find System.Speech and select it, and then click OK.For more information about gain access to the System.Speech namespaces, you could refer that: https://msdn.microsoft.com/en-us/library/office/hh361618(v=office.14).aspx
And a very easy introduction to Miccrosoft .NET Speech Synthesis: https://www.codeproject.com/Articles/28725/A-Very-Easy-Introduction-to-Microsoft-NET-Speech-S
Hope it will be helpful to you.
Best Regards,
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- Marked as answer by CakeMonsey Sunday, February 12, 2017 11:47 AM
Thursday, February 9, 2017 5:50 AM