简体   繁体   English

文本到语音Web应用程序如何在浏览器中打开

[英]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.

相关问题 如何编写一个读取文本并生成语音的应用程序 - How to write an application that reads text and produces speech 在网络浏览器中以编程方式打开文本文件 - Programmatically open a text file in a web browser 如何将连续的 Speech To Text 服务(使用 MS 认知服务)包含到写入页面中文本框的 ASP.NET Web 应用程序中? - How to include a continuous Speech To Text service(using MS Cognitive Service) into an ASP.NET web application that writes to text boxes in pages? 如何以编程方式强制.eml文件在Outlook中打开或允许从客户端Web应用程序从浏览器保存? - How to programatically force .eml file to open in Outlook or allow to save from browser from Client Web application? 如何在网络浏览器中打开 pdf 文件? - How to open a pdf file in the web browser? 如何在IE 8中打开Web浏览器控件 - how to open web browser control in IE 8 如何在应用程序中中断从文本到语音合成的播放? - How can I interrupt playing of text to speech synthesis in my application? 在C#控制台应用程序中的Web浏览器中打开pdf - Open pdf in web browser in C# console application 如何在文本到语音 C#/WPF 应用程序中知道语音的持续时间? - How to know the duration of a speech in a text-to-speech C#/WPF application? 如何在lightswitch应用程序中打开浏览器窗口? - How to open browser window in lightswitch application?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM