1.引用类库NAudio,Git地址 https://github.com/naudio/NAudio

2.添加如下代码和引用:

public float GetVoicePeakValue()
{
var enumerator = new MMDeviceEnumerator();
var CaptureDevices = enumerator.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToArray();
var defaultDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Console);
var selectedDevice = CaptureDevices.FirstOrDefault(c => c.ID == defaultDevice.ID);
return selectedDevice.AudioMeterInformation.MasterPeakValue;
}

 

相关文章:

  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2021-06-08
  • 2019-10-20
  • 2019-08-30
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-04-21
  • 2021-08-18
  • 2022-12-23
  • 2021-10-27
相关资源
相似解决方案