Public Access
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using MeetingAssistant.Transcription;
|
|
using MeetingAssistant.MeetingNotes;
|
|
|
|
namespace MeetingAssistant.Recording;
|
|
|
|
public interface ITranscriptStore
|
|
{
|
|
Task<TranscriptSession> CreateSessionAsync(CancellationToken cancellationToken);
|
|
|
|
Task<TranscriptSession> CreateSessionAsync(
|
|
MeetingAssistantOptions options,
|
|
DateTimeOffset startedAt,
|
|
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(
|
|
TranscriptSession session,
|
|
MeetingSessionArtifacts artifacts,
|
|
MeetingNote meetingNote,
|
|
CancellationToken cancellationToken);
|
|
}
|
|
|
|
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);
|