[英]Text to speech Web Application How to open in browser
I create the code for text to speech. 我创建了文本到语音的代码。 I want it to open web browser how to do this??
我要它打开Web浏览器该怎么做? I am using windows 7 OS.
我正在使用Windows 7 OS。 I also download xampp.
我还下载了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");
}
}
}
First, add this namespace 首先,添加此名称空间
using Microsoft.Win32;
using System.Diagnostics;
Then, run this code which will find the default web browser and launch it. 然后,运行此代码,它将找到默认的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();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.