我创建了文本到语音转换的代码。我想让它打开网页浏览器怎么做??我使用的是Windows7操作系统。我还下载了xampp。
using System.Speech.Synthesis;
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
synthesizer.Volume = 100; // 0...100
synthesizer.Rate = -2; // -10...10
// Synchronous
synthesizer.Speak("Hello World");
// Asynchronous
synthesizer.SpeakAsync("Hello World");
}
}
}发布于 2013-10-13 21:21:14
首先,添加此名称空间
using Microsoft.Win32;
using System.Diagnostics;然后,运行这段代码,它将找到默认的web浏览器并启动它。
Process p = new Process();
string browser = string.Empty;
RegistryKey key = null;
try
{
key = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command", false);
//trim off quotes
browser = key.GetValue(null).ToString().ToLower().Replace("\"", "");
if (!browser.EndsWith("exe"))
{
//get rid of everything after the ".exe"
browser = browser.Substring(0, browser.LastIndexOf(".exe") + 4);
}
}
finally
{
if (key != null) key.Close();
}
p.StartInfo.FileName = browser;
p.StartInfo.Arguments = "http://www.google.com";
p.Start();https://stackoverflow.com/questions/19331481
复制相似问题