如何在 Visual C#/C++ 中实现文本转语音 (TTS)?

发布于 2024-09-11 06:03:28 字数 394 浏览 2 评论 0原文

我想用 Visual C#/C++ 编写一个简单的 Windows 应用程序,让用户输入不同的文本片段,然后按一组热键随时收听 TTS 中的各个文本片段。该程序应该在后台运行时接受热键,甚至在全屏应用程序具有焦点时也应接受热键。

示例用例:用户输入“hello world”并将其保存为第一个文本段,然后输入“stack Overflow”并将其保存为第二个文本段。用户可以切换到另一个程序,然后按热键 CTRL-1 听到 TTS 说“hello world”,或按 CTRL-2 听到 TTS 说“堆栈溢出”。该程序当然应该能够完全离线运行(以防影响任何建议)

作为旁注,我对 Visual 编程相当陌生,但在 C#/C+ 方面有足够好的背景,所以即使我我主要是在 TTS 部分寻求帮助,如果有人以前做过此类事情,我愿意接受任何类型的建议。

I want to write a simple Windows app in Visual C#/C++ that lets users input different segments of text, and then press a set of hotkeys to hear the various text segments in TTS at any time. The program should accept hotkeys while running in background or even when fullscreen applications have focus.

Example use case: user enters "hello world" and saves it as the first text segment, and then enters "stack overflow" and saves it as the second text segment. The user can switch to another program, then press hotkey CTRL-1 to hear the TTS say "hello world" or CTRL-2 to hear the TTS say "stack overflow." The program should of course be able to run entirely offline (just in case that affects any suggestions)

As a sidenote, I'm fairly new to programming in Visual whatever, but have a decent enough background in C#/C+, so even though I'm mainly looking for help on the TTS part, I'm open to suggestions of any kind if someone's done this kind of thing before.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

葮薆情 2024-09-18 06:03:28

如果你想谈论 C# 的内容,请使用 Introp.SpeechLib.dll

例如:

private void ReadText()
        {
            int iCounter = 0;
            while (Convert.ToInt32(numericUpDown1.Value) > iCounter)
            {
                SpVoice spVoice = new SpVoice();
                spVoice.Speak("Hello World", SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
                spVoice.WaitUntilDone(Timeout.Infinite);
                iCounter = iCounter + 1;
            }
        }

阅读以下内容:语音技术

if you want to talk something on C# use Introp.SpeechLib.dll

E.g:

private void ReadText()
        {
            int iCounter = 0;
            while (Convert.ToInt32(numericUpDown1.Value) > iCounter)
            {
                SpVoice spVoice = new SpVoice();
                spVoice.Speak("Hello World", SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
                spVoice.WaitUntilDone(Timeout.Infinite);
                iCounter = iCounter + 1;
            }
        }

read this: Speech Technologies

自我难过 2024-09-18 06:03:28

参考System.Speech.dll。您可以实例化 System.Speech.Synthesis.Synthesizer 并调用 .Speak("TEXT HERE");

Reference System.Speech.dll. You can instantiate a System.Speech.Synthesis.Synthesizer and call .Speak("TEXT HERE");

小巷里的女流氓 2024-09-18 06:03:28

您必须使用 Microsoft 语音 SDK。

查看此链接了解详细信息:

http: //dhavalshah.wordpress.com/2008/09/16/text-to-speech-in-c/

You have to use the Microsoft Speech SDK.

Have a look at this link for details:

http://dhavalshah.wordpress.com/2008/09/16/text-to-speech-in-c/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文