简体   繁体   English

检测语音输出和语音合成库建议

[英]Detect audio output + suggestion for a speech synthesis library

I would like to detect if my PC is playing any kind of audio (music/movie anything). 我想检测我的PC是否正在播放任何类型的音频(音乐/电影)。
I wrote an app which notifies me of my twitter updates. 我写了一个应用程序,通知我Twitter更新。 Now I would like to add a speech synthesis to it but I only want to play out the messages if there is no music or movie playing. 现在,我想为其添加语音合成,但是我只想在没有音乐或电影播放的情况下播放消息。

Although I'm using C# I don't mind doing the detection using C++ and then integrating it. 尽管我使用的是C#,但我不介意使用C ++进行检测,然后将其集成。

So the questions are: 所以问题是:

1) How can I detect audio output? 1)如何检测音频输出?
2) What is the best free speech synthesis library for windows? 2)什么是Windows最佳的免费语音合成库?

After some time looking through the MSDN I have found the solution. 经过一段时间的MSDN浏览后,我找到了解决方案。

Using the loopback recording you can listen to what's being outputted to the audio output device. 使用回送记录,您可以收听正在输出到音频输出设备的内容。

http://msdn.microsoft.com/en-gb/library/windows/desktop/dd316551(v=vs.85).aspx http://msdn.microsoft.com/zh-CN/library/windows/desktop/dd316551(v=vs.85).aspx

This link also refers to an example of how to capture the stream: 此链接还引用了如何捕获流的示例:

http://msdn.microsoft.com/en-gb/library/windows/desktop/dd370800(v=vs.85).aspx http://msdn.microsoft.com/zh-CN/library/windows/desktop/dd370800(v=vs.85).aspx

In here you can get the buffer data as shown in the example by calling: 在这里,您可以通过调用以下示例获取缓冲区数据:

pCaptureClient->GetBuffer(...) pCaptureClient-> GetBuffer(...)

All you have to do then is to check the value of those bytes. 然后,您要做的就是检查这些字节的值。 If they are all 0s then there is nothing playin.. 如果它们全为0,则没有任何作用。

For the speech synthesis I used the SpeechSynthesizer .NET class 对于语音合成,我使用了SpeechSynthesizer .NET类

http://msdn.microsoft.com/en-us/library/system.speech.synthesis.speechsynthesizer.aspx http://msdn.microsoft.com/zh-CN/library/system.speech.synthesis.speechsynthesizer.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM