I have been using Microsoft.Speech synthesizer for years on different PCs and different versions of Windows. I am trying to set up the development and support environment on a new Windows 10 PC and I can't get spsynthesizer to work correctly. I have downloaded the Microsoft SDK5.1 and the voices twice now to make sure nothing was corrupted. I have stepped through each line of code with the debugger and everything works as expected until the call to spsynthesizer.speak...the call never speaks and never returns to the program. I have tried executing as x86, x64 and AnyCPU and I have a reference entry to Microsoft.Speech.
Any suggestions? Here is the simple C# test application.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Speech.Synthesis;
namespace test_text_to_speech
{
class Program
{
static void Main(string[] args)
{
Microsoft.Speech.Synthesis.SpeechSynthesizer spsynthesizer = new Microsoft.Speech.Synthesis.SpeechSynthesizer();
System.Collections.ObjectModel.ReadOnlyCollection<Microsoft.Speech.Synthesis.InstalledVoice> myvoices;
myvoices = spsynthesizer.GetInstalledVoices();
spsynthesizer.SelectVoice(myvoices[0].VoiceInfo.Name); //Invoke the one which you want
spsynthesizer.Volume = 100; // Can be 1 - 100
spsynthesizer.Rate = 1; // can be 1 - 10
spsynthesizer.SetOutputToDefaultAudioDevice();
PromptBuilder Thanks = new PromptBuilder();
Thanks.AppendSsmlMarkup("<voice xml:lang=\"en-US\">");
Thanks.StartStyle(new PromptStyle(PromptEmphasis.Strong));
Thanks.AppendText("Hello World");
Thanks.EndStyle();
Thanks.AppendSsmlMarkup("</voice>");
spsynthesizer.Speak(Thanks);
spsynthesizer.Speak("try with no markup");
}
}
}
Related
I am currently working with Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 and have used an MS c# example program to test the built-in unit test and code coverage function. The unit test is working perfectly fine, but everytime I try to start code coverage after the test finished, I get an error message saying:
"Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see: http://go.microsoft.com/fwlink/?LinkID=253731.".
Of course, I checked the link for troubleshooting and worked through all listed issues there, but without any success. I also tried several solutions which should have worked in earlier versions (use command promp to instrument binary or to run code coverage, deleting test results Folder and the VS Solution User Option .suo file, etc.), but still haven't found anything useful working for my case.
Does anybody face the same problem or knows a possible solution for it?
Thank you very much in advance!
Best,
Steve
PS: I am using the standard settings, but with all optimizations turned off. My test project is located in the same solution as my source project I want to test. Here is the code for the example program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace codecoverage
{
public class Program
{
static void Main(string[] args)
{
Program prog = new Program();
prog.TestFunction(0);
}
public int TestFunction(int input)
{
if (input > 0)
{
return 1;
}
else
{
return 0;
}
}
}
}
The Test Class is defined as followed:
using Microsoft.VisualStudio.TestTools.UnitTesting;
using codecoverage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace codecoverage.Tests
{
[TestClass()]
public class ProgramTests
{
[TestMethod()]
public void TestFunctionTest2()
{
Program target = new Program();
int input = 1;
int expected = 1;
int actual;
actual = target.TestFunction(input);
Assert.AreEqual(expected, actual, "CodeCoverage.Program.TestFunction did not return the expected value.");
}
}
}
i have been looking for the solution. and found that it's actually a PDB file problem. all you need to do is to go to this linker tab->debugging. and set option "Generate full program database file" to Yes. this is due to the change VS2015 introduced for /Debug:FASTLINK. setting it to 'yes' would override it.
Whenever it comes to this line, this error appears:
using (var client = new HttpClient())
{
var json = await client.GetStringAsync("http://mvalivros.azurewebsites.net/api/livros");
var livros = JsonConvert.DeserializeObject<List<Model.Livro>>(json);
return livros;
}
A new tab appears in VS that says "Frame not in module."
It happens whenever the thread arrives at the using line.
Frame not in module
This is code complete...
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace LivrosApp.ApiLivros
{
public static class Api
{
public static async Task<IList<Model.Livro>> GetAsync()
{
using (var client = new HttpClient())
{
var json = await client.GetStringAsync("http://mvalivros.azurewebsites.net/api/livros");
var livros = JsonConvert.DeserializeObject<List<Model.Livro>>(json);
return livros;
}
}
}
}
Annoying when this happens!!
There is not one solution to this, have had this issue in past and few things you can try:
Change linking options -->Clean -->build
Change fast deployment --> build
Make sure mdb files are been generated and switch debug info
generation to all/pdb files and rebuild
Exception settings -> Common Language Runtime Exceptions (should be ticked) If unticked tick the parent level so that everything below it is ticked
Tools -> Options -> Debugging -> General -> Enable Just My Code
(Ticked)
If none of them works then try stepping over (F10) instead of step
into (F11)
Hopefully atleast one solution works!!
I had the same problem and it worked for me after I make the following change.
Go to Debug -> Exceptions -> Uncheck Common Language Runtime Exception
Source where I get the solution from: Debbuger doesn't work frame not in module.
I have a .r file which fetches data from database, performs some calculation and write back to a new table in database.
I am trying to execute the .r file from C# using visual studio 2010.
The C# code is mentioned below.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using RDotNet;
using RDotNet.Devices;
using RDotNet.Internals;
namespace EmbeddAssembly
{
class Program
{
static void Main(string[] args)
{
string rhome = System.Environment.GetEnvironmentVariable("R_HOME");
if (string.IsNullOrEmpty(rhome))
rhome = #"C:\Program Files\R\R-2.14.1";
System.Environment.SetEnvironmentVariable("R_HOME", rhome);
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + rhome + #"binx64");
// Set the folder in which R.dll locates.
//REngine.SetDllDirectory(#"C:Program FilesRR-2.12.0bini386″);
REngine.SetDllDirectory(#"C:\Program Files\R\R-2.14.1\bin\x64");
// REngine e = REngine.CreateInstance("test", new[] { "" });
using (REngine engine = REngine.CreateInstance("RDotNet", new[] { "-q" })) // quiet mode
{
foreach (string path in engine.EagerEvaluate(".libPaths()").AsCharacter())
{
Console.WriteLine(path);
}
engine.Evaluate(".libPaths(C:\\Program Files\\R\\R-2.14.1\\library)");
engine.Evaluate("source(C:\\Users\\..\\Documents\\Visual Studio 2010\\Projects\\EmbeddAssembly\\multi.r)");
Console.ReadLine();
}
}
}
}
I am not getting any error but it is not calling the .r file.
The code in r file works fine because I am able to retrive data and write into the table. However on calling that from C# it is not performing any action.
You are missing character delimitors around arguments to the R functions called. Also, avoid using backslashes when passing strings to R.NET's Evaluate. You may need to end up having quadruple backslashes (or even more if using regular expressions) to get things to work.
You should use something like:
engine.Evaluate(".libPaths('C:/Program Files/R/R-2.14.1/library')");
engine.Evaluate("source('C:/Users/Documents/Visual Studio 2010/Projects/EmbeddAssembly/multi.r')");
It seems you are using a very old version of R.NET; I strongly advise you to use R.NET.Community on NuGet. I know there is an R.NET nuget feed still up too, but this appears not maintained anymore. Also, FYI, R.NET latest reference documentation is now on a GitHub page
did a lot of looking around and I couldn't find any solution.
Goal: To blink the Camera flash LED on my Windows 8.1 tablet. Using Windows 8.1 to develop and VS2013.
The InitializeAsync method allows the application to initialize the Camera and Microphone with the default settings
I built the app as a Windows Store application and it worked flawlessly.
I need the file to be an executable and I need to convert it to a console application
I get the following error when I do mc.InitializeAsync "Error 1 'await' requires that the type 'Windows.Foundation.IAsyncAction' have a suitable GetAwaiter method. Are you missing a using directive for 'System'? c:\users\levi\documents\visual studio 2013\projects\ledblinkerconsole\ledblinkerconsole\torch.cs 16 14 LEDBlinkerConsole
I have no idea how to initialize the camera via a Console application
Any other ways to blink the LED flash are greatly appreciated. I do not have access to the memory locations though to do it in C++.
Thanks guys!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Media.Devices;
using Windows.Media.Capture;
namespace LEDBlinkerConsole
{
class Torch
{
public async static void BlinkLED()
{
MediaCapture mc = new MediaCapture();
await mc.InitializeAsync();
Console.WriteLine("Please type \"flash\" to flash the LED\n");
string consInput = Console.ReadLine();
if (consInput.ToUpper() == "FLASH")
{
if (mc.VideoDeviceController.TorchControl.Supported == true)
{
mc.VideoDeviceController.TorchControl.Enabled = true;
mc.VideoDeviceController.TorchControl.PowerPercent = 100;
}
}
}
}
}
I figured it out. I referenced "System.Runtime" and I had to reference "System.Runtime.Windowsruntime". I had to delete the reference to "System.Runtime" in order for it to work. More info here about the Async calls from a non-metro app:
http://www.wintellect.com/blogs/jeffreyr/using-the-windows-runtime-from-a-non-metro-application
I´m new to C# -- started three days ago because of an especific need regarding usb drives. Reading here and there I could have the following code to work. What I want is to know when an user inserts a pendrive in the usb port.
The only problem is the that on XP32 (the only XP I tested) the event will never be detected. On Windows 7 it runs perfectly.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;
using System.Diagnostics;
using System.Threading;
using System.IO;
using Microsoft.Win32;
using System.Security.Permissions;
namespace X
{
class Program
{
static void Main(string[] args)
{
ManagementEventWatcher watcher = new ManagementEventWatcher();
WqlEventQuery query = new WqlEventQuery("SELECT * FROM Win32_VolumeChangeEvent WHERE EventType = 2");
watcher.Query = query;
watcher.Start();
watcher.WaitForNextEvent();
// DO something if a pen drive (or any storage device) is inserted.
// Works fine on Windows 7
// XP will ignore the event...
}
}
}
Any suggestions will be very welcome!
Regards,
Sergio
Looks like you need XP service pack 3 for it to work (SP2 on x64).