【发布时间】:2014-07-12 20:00:20
【问题描述】:
我有一个 TTS 程序(第三方),我编写了一个使用该程序的 c# 应用程序。 (输入我的应用程序并按下按钮移动鼠标并单击第三方应用程序)。
我需要知道演讲是否结束。关于如何确定声卡是否播放任何声音有什么想法吗?
【问题讨论】:
我有一个 TTS 程序(第三方),我编写了一个使用该程序的 c# 应用程序。 (输入我的应用程序并按下按钮移动鼠标并单击第三方应用程序)。
我需要知道演讲是否结束。关于如何确定声卡是否播放任何声音有什么想法吗?
【问题讨论】:
我按照 this power-shell script. 使用 C# 成功地做到了,你只需要删除第一行和最后一行,就可以从这个 power-shell 脚本中创建一个 C# 类
【讨论】:
您可以使用 CSCore。
在这里下载 -> https://github.com/filoe/cscore
将这些行粘贴到控制台项目中。
using System;
using CSCore.CoreAudioAPI;
namespace AudioDetector
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(IsAudioPlaying(GetDefaultRenderDevice()));
Console.ReadLine();
}
public static MMDevice GetDefaultRenderDevice()
{
using (var enumerator = new MMDeviceEnumerator())
{
return enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
}
}
public static bool IsAudioPlaying(MMDevice device)
{
using (var meter = AudioMeterInformation.FromDevice(device))
{
return meter.PeakValue > 0;
}
}
}
}
在 YouTube、音乐播放器等上播放音乐...
运行程序。
如果当前正在播放音频,它会自动通知(true/false)。
【讨论】:
【讨论】:
【讨论】: