Add transcript line workflow rules
PR and Push Build/Test / build-and-test (push) Failing after 13m27s

This commit is contained in:
2026-06-03 11:24:11 +02:00
parent 50daa88389
commit 40853115c5
20 changed files with 627 additions and 70 deletions
+43 -1
View File
@@ -14,11 +14,30 @@ public interface ITranscriptStore
return CreateSessionAsync(cancellationToken);
}
Task AppendAsync(TranscriptSession session, TranscriptionSegment segment, CancellationToken cancellationToken);
Task AppendAsync(TranscriptSession session, TranscriptionSegment segment, CancellationToken cancellationToken)
{
return AppendLineAsync(
session,
TranscriptLineFormatter.Format(segment).Line,
cancellationToken);
}
Task AppendLineAsync(TranscriptSession session, string line, CancellationToken cancellationToken);
Task ReplaceAsync(
TranscriptSession session,
IReadOnlyList<TranscriptionSegment> replacementSegments,
CancellationToken cancellationToken)
{
return ReplaceLinesAsync(
session,
replacementSegments.Select(segment => TranscriptLineFormatter.Format(segment).Line).ToList(),
cancellationToken);
}
Task ReplaceLinesAsync(
TranscriptSession session,
IReadOnlyList<string> replacementLines,
CancellationToken cancellationToken);
Task UpdateMetadataAsync(
@@ -29,3 +48,26 @@ public interface ITranscriptStore
}
public sealed record TranscriptSession(string TranscriptPath);
public static class TranscriptLineFormatter
{
public static FormattedTranscriptLine Format(TranscriptionSegment segment)
{
var speaker = NormalizeSpeaker(segment.Speaker);
return new FormattedTranscriptLine(
$"[{segment.Start:hh\\:mm\\:ss}] {speaker}: {segment.Text}",
speaker);
}
public static string FormatSegmentLine(TranscriptionSegment segment)
{
return Format(segment).Line;
}
public static string NormalizeSpeaker(string? speaker)
{
return string.IsNullOrWhiteSpace(speaker) ? "Unknown" : speaker;
}
}
public sealed record FormattedTranscriptLine(string Line, string Speaker);
@@ -433,7 +433,7 @@ public sealed class MeetingRecordingCoordinator
"System",
$"Transcription profile changed to {targetProfile.Name}.");
run.AddLiveSegment(marker);
await transcriptStore.AppendAsync(run.Session, marker, cancellationToken);
await AppendTranscriptSegmentAsync(run, marker, cancellationToken);
run.ReplacePipeline(pipeline, pipelineOptions, targetProfile.Options, targetProfile.Name);
run.AddLiveTranscriptTask(Task.Run(
@@ -598,10 +598,48 @@ public sealed class MeetingRecordingCoordinator
var relabeledSegment = run.Relabel(segment);
run.AddLiveSegment(relabeledSegment);
await transcriptStore.AppendAsync(run.Session, relabeledSegment, cancellationToken);
await AppendTranscriptSegmentAsync(run, relabeledSegment, cancellationToken);
}
}
private async Task AppendTranscriptSegmentAsync(
RecordingRun run,
TranscriptionSegment segment,
CancellationToken cancellationToken)
{
var line = await TransformTranscriptLineAsync(run, segment, cancellationToken);
await transcriptStore.AppendLineAsync(run.Session, line, cancellationToken);
}
private async Task ReplaceTranscriptSegmentsAsync(
RecordingRun run,
IReadOnlyList<TranscriptionSegment> segments,
CancellationToken cancellationToken)
{
var lines = new List<string>(segments.Count);
foreach (var segment in segments)
{
lines.Add(await TransformTranscriptLineAsync(run, segment, cancellationToken));
}
await transcriptStore.ReplaceLinesAsync(run.Session, lines, cancellationToken);
}
private async Task<string> TransformTranscriptLineAsync(
RecordingRun run,
TranscriptionSegment segment,
CancellationToken cancellationToken)
{
var formatted = TranscriptLineFormatter.Format(segment);
return await meetingWorkflowEngine.TransformTranscriptLineAsync(
MeetingWorkflowEvent.TranscriptLine(
run.Artifacts,
formatted.Line,
formatted.Speaker),
run.Options,
cancellationToken);
}
private async Task RunInactivitySafeguardAsync(RecordingRun run)
{
var safeguardOptions = run.Options.Recording.InactivitySafeguard;
@@ -778,8 +816,8 @@ public sealed class MeetingRecordingCoordinator
cancellationToken);
if (run.AddSpeakerMappings(result.SpeakerMappings))
{
await transcriptStore.ReplaceAsync(
run.Session,
await ReplaceTranscriptSegmentsAsync(
run,
run.GetRelabeledLiveSegmentsSnapshot(),
cancellationToken);
}
@@ -995,7 +1033,7 @@ public sealed class MeetingRecordingCoordinator
liveSegments.Count,
liveSamples.Count,
liveMappings.Count);
await transcriptStore.ReplaceAsync(run.Session, liveSegments, cancellationToken);
await ReplaceTranscriptSegmentsAsync(run, liveSegments, cancellationToken);
return;
}
@@ -1040,7 +1078,7 @@ public sealed class MeetingRecordingCoordinator
finishedSpeakerResult.Segments.Count,
samples.Count,
knownSpeakerMappings.Count);
await transcriptStore.ReplaceAsync(run.Session, finishedSpeakerResult.Segments, cancellationToken);
await ReplaceTranscriptSegmentsAsync(run, finishedSpeakerResult.Segments, cancellationToken);
}
private async Task<SpeakerIdentificationResult> IdentifyFinishedSpeakersForTranscriptAsync(
@@ -1177,7 +1215,7 @@ public sealed class MeetingRecordingCoordinator
run.MeetingNotePath,
run.Options,
cancellationToken);
await transcriptStore.ReplaceAsync(run.Session, result.Segments, cancellationToken);
await ReplaceTranscriptSegmentsAsync(run, result.Segments, cancellationToken);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
@@ -35,14 +35,14 @@ public sealed class VaultTranscriptStore : ITranscriptStore
return new TranscriptSession(path);
}
public Task AppendAsync(TranscriptSession session, TranscriptionSegment segment, CancellationToken cancellationToken)
public Task AppendLineAsync(TranscriptSession session, string line, CancellationToken cancellationToken)
{
return AppendToBodyAsync(session.TranscriptPath, FormatSegment(segment), cancellationToken);
return AppendToBodyAsync(session.TranscriptPath, line + Environment.NewLine, cancellationToken);
}
public Task ReplaceAsync(
public Task ReplaceLinesAsync(
TranscriptSession session,
IReadOnlyList<TranscriptionSegment> replacementSegments,
IReadOnlyList<string> replacementLines,
CancellationToken cancellationToken)
{
var existing = File.Exists(session.TranscriptPath)
@@ -52,7 +52,7 @@ public sealed class VaultTranscriptStore : ITranscriptStore
var body = "# Meeting Transcript"
+ Environment.NewLine
+ Environment.NewLine
+ string.Concat(replacementSegments.Select(FormatSegment));
+ string.Concat(replacementLines.Select(line => line + Environment.NewLine));
var content = string.IsNullOrWhiteSpace(frontmatter)
? body
: "---" + Environment.NewLine + frontmatter + Environment.NewLine + "---" + Environment.NewLine + Environment.NewLine + body;
@@ -80,12 +80,6 @@ public sealed class VaultTranscriptStore : ITranscriptStore
cancellationToken);
}
private static string FormatSegment(TranscriptionSegment segment)
{
var speaker = string.IsNullOrWhiteSpace(segment.Speaker) ? "Unknown" : segment.Speaker;
return $"[{segment.Start:hh\\:mm\\:ss}] {speaker}: {segment.Text}{Environment.NewLine}";
}
private static async Task AppendToBodyAsync(
string path,
string text,