Public Access
Add meeting assistant speech and summary automation
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace MeetingAssistant.Transcription;
|
||||
|
||||
public sealed class MarkdownDictationWordStore : IDictationWordStore
|
||||
{
|
||||
private readonly MeetingAssistantOptions options;
|
||||
|
||||
public MarkdownDictationWordStore(IOptions<MeetingAssistantOptions> options)
|
||||
{
|
||||
this.options = options.Value;
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<string>> ReadWordsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var path = GetPath();
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var lines = await File.ReadAllLinesAsync(path, cancellationToken);
|
||||
return Normalize(lines);
|
||||
}
|
||||
|
||||
public async Task<IReadOnlyList<string>> AddWordAsync(string word, CancellationToken cancellationToken)
|
||||
{
|
||||
var path = GetPath();
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path)!);
|
||||
var existing = File.Exists(path)
|
||||
? await File.ReadAllLinesAsync(path, cancellationToken)
|
||||
: [];
|
||||
var words = Normalize(existing.Append(word));
|
||||
|
||||
await File.WriteAllTextAsync(
|
||||
path,
|
||||
string.Join(Environment.NewLine, words.Select(value => $"- {value}")) + Environment.NewLine,
|
||||
cancellationToken);
|
||||
return words;
|
||||
}
|
||||
|
||||
private string GetPath()
|
||||
{
|
||||
return VaultPath.Resolve(options.Vault, options.Vault.DictationWordsPath);
|
||||
}
|
||||
|
||||
internal static IReadOnlyList<string> Normalize(IEnumerable<string> lines)
|
||||
{
|
||||
return lines
|
||||
.Select(ParseLine)
|
||||
.Where(word => !string.IsNullOrWhiteSpace(word))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.Order(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static string ParseLine(string line)
|
||||
{
|
||||
var trimmed = line.Trim();
|
||||
if (trimmed.StartsWith("- ", StringComparison.Ordinal) ||
|
||||
trimmed.StartsWith("* ", StringComparison.Ordinal))
|
||||
{
|
||||
trimmed = trimmed[2..].Trim();
|
||||
}
|
||||
|
||||
return trimmed.Trim('`', '"', '\'').Trim();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user