Public Access
Add meeting assistant speech and summary automation
This commit is contained in:
@@ -20,6 +20,7 @@ public sealed class WhisperLocalStreamingTranscriptionProvider : IStreamingTrans
|
||||
|
||||
public async IAsyncEnumerable<TranscriptionSegment> TranscribeAsync(
|
||||
IAsyncEnumerable<AudioChunk> audio,
|
||||
SpeechRecognitionPipelineOptions pipelineOptions,
|
||||
[System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken)
|
||||
{
|
||||
var modelPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(options.WhisperLocal.ModelPath));
|
||||
@@ -29,9 +30,7 @@ public sealed class WhisperLocalStreamingTranscriptionProvider : IStreamingTrans
|
||||
}
|
||||
|
||||
using var factory = WhisperFactory.FromPath(modelPath);
|
||||
using var processor = factory.CreateBuilder()
|
||||
.WithLanguage(options.WhisperLocal.Language)
|
||||
.Build();
|
||||
using var processor = CreateProcessor(factory, pipelineOptions.DictationWords);
|
||||
|
||||
var window = new List<AudioChunk>();
|
||||
var windowDuration = TimeSpan.Zero;
|
||||
@@ -119,6 +118,37 @@ public sealed class WhisperLocalStreamingTranscriptionProvider : IStreamingTrans
|
||||
}
|
||||
}
|
||||
|
||||
private WhisperProcessor CreateProcessor(
|
||||
WhisperFactory factory,
|
||||
IReadOnlyList<string>? dictationWords)
|
||||
{
|
||||
var builder = factory.CreateBuilder()
|
||||
.WithLanguage(options.WhisperLocal.Language);
|
||||
var prompt = BuildPrompt(dictationWords);
|
||||
if (!string.IsNullOrWhiteSpace(prompt))
|
||||
{
|
||||
builder.WithPrompt(prompt)
|
||||
.WithCarryInitialPrompt(true);
|
||||
logger.LogInformation(
|
||||
"Configured Whisper prompt with {WordCount} dictation word(s)",
|
||||
dictationWords?.Count ?? 0);
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
internal static string BuildPrompt(IReadOnlyList<string>? dictationWords)
|
||||
{
|
||||
var words = (dictationWords ?? [])
|
||||
.Select(word => word.Trim())
|
||||
.Where(word => !string.IsNullOrWhiteSpace(word))
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
return words.Count == 0
|
||||
? ""
|
||||
: "Prefer these domain terms and acronyms: " + string.Join(", ", words) + ".";
|
||||
}
|
||||
|
||||
private static bool IsControlMarker(string text)
|
||||
{
|
||||
return text is "[BLANK_AUDIO]" or "[MUSIC]" or "[NO_SPEECH]" or "[SILENCE]";
|
||||
|
||||
Reference in New Issue
Block a user