Pan!cKk
Pan!cKk
CC#
Created by Pan!cKk on 2/12/2025 in #help
Assignment Problem
regarding the "limited data", that's how my app works, it processes a media stream in 1minute chunks...
14 replies
CC#
Created by Pan!cKk on 2/12/2025 in #help
Assignment Problem
No description
14 replies
CC#
Created by Pan!cKk on 2/12/2025 in #help
Assignment Problem
No description
14 replies
CC#
Created by Pan!cKk on 2/12/2025 in #help
Assignment Problem
but it is still not efficient enough
14 replies
CC#
Created by Pan!cKk on 2/12/2025 in #help
Assignment Problem
This method is the best i've got so far...
private static List<Segment> AssignSpeakers(List<DiarizationModel> diarization, List<Segment> segments)
{
string previousSpeaker = null;

foreach (var segment in segments)
{
string assignedSpeaker = null;
double bestScore = 0.0;

foreach (var entry in diarization)
{
double overlapStart = Math.Max(segment.StartTime, entry.Start);
double overlapEnd = Math.Min(segment.EndTime, entry.End);
double overlap = Math.Max(0, overlapEnd - overlapStart);

if (overlap <= 0)
continue;

double score = overlap;
double entryDuration = entry.End - entry.Start;
double ratio = overlap / entryDuration;

score += ratio;

if (Math.Abs(segment.StartTime - entry.Start) < 1.0)
score += 0.5;

if (Math.Abs(segment.EndTime - entry.End) < 1.0)
score += 0.5;

if (score > bestScore)
{
bestScore = score;
assignedSpeaker = entry.Speaker;
}
}

if (assignedSpeaker == null)
{
double closestDistance = double.MaxValue;
foreach (var entry in diarization)
{
double distance = Math.Min(Math.Abs(segment.StartTime - entry.End), Math.Abs(segment.EndTime - entry.Start));

if (distance < closestDistance)
{
closestDistance = distance;
assignedSpeaker = entry.Speaker;
}
}

}

segment.Speaker = assignedSpeaker;
previousSpeaker = assignedSpeaker;
}

return segments;
}
private static List<Segment> AssignSpeakers(List<DiarizationModel> diarization, List<Segment> segments)
{
string previousSpeaker = null;

foreach (var segment in segments)
{
string assignedSpeaker = null;
double bestScore = 0.0;

foreach (var entry in diarization)
{
double overlapStart = Math.Max(segment.StartTime, entry.Start);
double overlapEnd = Math.Min(segment.EndTime, entry.End);
double overlap = Math.Max(0, overlapEnd - overlapStart);

if (overlap <= 0)
continue;

double score = overlap;
double entryDuration = entry.End - entry.Start;
double ratio = overlap / entryDuration;

score += ratio;

if (Math.Abs(segment.StartTime - entry.Start) < 1.0)
score += 0.5;

if (Math.Abs(segment.EndTime - entry.End) < 1.0)
score += 0.5;

if (score > bestScore)
{
bestScore = score;
assignedSpeaker = entry.Speaker;
}
}

if (assignedSpeaker == null)
{
double closestDistance = double.MaxValue;
foreach (var entry in diarization)
{
double distance = Math.Min(Math.Abs(segment.StartTime - entry.End), Math.Abs(segment.EndTime - entry.Start));

if (distance < closestDistance)
{
closestDistance = distance;
assignedSpeaker = entry.Speaker;
}
}

}

segment.Speaker = assignedSpeaker;
previousSpeaker = assignedSpeaker;
}

return segments;
}
14 replies
CC#
Created by Pan!cKk on 2/12/2025 in #help
Assignment Problem
I tried that approach, but it is not quite efficient... It really varies, when speakers overlap quite often, and there are abrupt speaker changes, it fails to choose the correct one...
14 replies
CC#
Created by Pan!cKk on 7/16/2024 in #help
Multi-Instance Application with SignalR and Redis as backplane
UPDATE I believe the fix for this was configuring sticky-sessions on the ingress of the service in kubernetes, it seems to be working now
2 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
I will take a shot at this approach, thank you :)
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
I can download it chunk by chunk and do a multi part upload, within a ReadAsStream...?
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
What I want is to implement something that download a file part by part, and upload them to storage part by part... Download Part 1, Upload Part 1 Continue Downloading the second part, Upload Part 2 ... How many parts are decided base on the total fileSize / some chunkSize (in bytes)
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
it does not happen when try to read the whole file 🤷‍♂️
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
or could you send me some example? @Jimmacle
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
is there any article or stack overflow thread where I can rely?
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
It was something like this:
private async Task<byte[]> DownloadChunk(HttpResponseMessage response, long start, long end)
{
using(var memoryStream = new MemoryStream())
using(var responseStream = await response.Content.ReadAsStreamAsync())
{
var bufferSize = 10 * 1024 * 1024; // 10MB
var buffer = new byte[bufferSize];
int bytesRead;
int totalBytesRead = 0;

// Seek to the start position
responseStream.Seek(start, SeekOrigin.Begin);

while(totalBytesRead < end - start && (bytesRead = await responseStream.ReadAsync(buffer, 0, bufferSize)) > 0)
{
await memoryStream.WriteAsync(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

return memoryStream.ToArray();
}
}
private async Task<byte[]> DownloadChunk(HttpResponseMessage response, long start, long end)
{
using(var memoryStream = new MemoryStream())
using(var responseStream = await response.Content.ReadAsStreamAsync())
{
var bufferSize = 10 * 1024 * 1024; // 10MB
var buffer = new byte[bufferSize];
int bytesRead;
int totalBytesRead = 0;

// Seek to the start position
responseStream.Seek(start, SeekOrigin.Begin);

while(totalBytesRead < end - start && (bytesRead = await responseStream.ReadAsync(buffer, 0, bufferSize)) > 0)
{
await memoryStream.WriteAsync(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}

return memoryStream.ToArray();
}
}
I am trying different methods, so the current state of my code has changed...
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
I tried using Streams, but I get such an error: The response ended prematurely, with at least 9823402 additional bytes expected.
20 replies
CC#
Created by Pan!cKk on 4/23/2024 in #help
Download File in Chunks
FIle is to be downloaded from a given URL
20 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
thank you for your help <3
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
fair
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
How may I conclude if it does or not?
31 replies
CC#
Created by Pan!cKk on 3/19/2024 in #help
Enum Capabilities
Yes, now I am. I tried your suggestion, but it doesn't seem to do the work (at least not what I am looking for...)
31 replies