Public Access
22 lines
491 B
C#
22 lines
491 B
C#
namespace MeetingAssistant.Recording;
|
|
|
|
public sealed record AudioChunk(
|
|
byte[] Pcm,
|
|
int SampleRate,
|
|
int Channels)
|
|
{
|
|
public TimeSpan Duration
|
|
{
|
|
get
|
|
{
|
|
var bytesPerSampleFrame = Channels * sizeof(short);
|
|
if (bytesPerSampleFrame <= 0 || SampleRate <= 0)
|
|
{
|
|
return TimeSpan.Zero;
|
|
}
|
|
|
|
return TimeSpan.FromSeconds((double)Pcm.Length / bytesPerSampleFrame / SampleRate);
|
|
}
|
|
}
|
|
}
|