修复 sv语言转录函数最后截断漏话问题
This commit is contained in:
parent
18af52484a
commit
374c582cd1
|
|
@ -110,6 +110,10 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取语音字幕
|
||||
/// </summary>
|
||||
|
|
@ -120,7 +124,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
var filePath = Path.Combine(task.LocalPath(), task + ".wav");
|
||||
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
|
||||
throw new Exception("task 音频路径未找到");
|
||||
await TaskHandle(new WaveReader(filePath));
|
||||
await TaskHandle(new WaveReader(filePath), task);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -144,14 +148,14 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
for (int i = 0; i != numIter; ++i)
|
||||
{
|
||||
int start = i * windowSize;
|
||||
//float[] samples = new float[windowSize];
|
||||
//Array.Copy(reader.Samples, start, samples, 0, windowSize);
|
||||
//VAD.AcceptWaveform(samples);
|
||||
float[] samples = new float[windowSize];
|
||||
Array.Copy(reader.Samples, start, samples, 0, windowSize);
|
||||
VAD.AcceptWaveform(samples);
|
||||
|
||||
Memory<float> samples = new float[windowSize];
|
||||
Memory<float> sourceSpan = reader.Samples.AsMemory(start, windowSize);
|
||||
sourceSpan.CopyTo(samples);
|
||||
VAD.AcceptWaveform(samples.ToArray());
|
||||
//Memory<float> samples = new float[windowSize];
|
||||
//Memory<float> sourceSpan = reader.Samples.AsMemory(start, windowSize);
|
||||
//sourceSpan.CopyTo(samples);
|
||||
//VAD.AcceptWaveform(samples.ToArray());
|
||||
|
||||
//是否检测到语音
|
||||
if (VAD.IsSpeechDetected())
|
||||
|
|
@ -161,9 +165,9 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
await VAD.ReadNext(res, totalSecond, task);
|
||||
}
|
||||
}
|
||||
VAD.Flush();
|
||||
while (!VAD.IsEmpty())
|
||||
await VAD.ReadNext(res, totalSecond, task);
|
||||
VAD.Flush();
|
||||
//如果携带任务ID
|
||||
if (!string.IsNullOrEmpty(task))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,19 +14,12 @@ namespace VideoAnalysisCore.Common
|
|||
{
|
||||
public class ExceptionFilter : IAsyncExceptionFilter
|
||||
{
|
||||
readonly NavigationManager nm;
|
||||
public ExceptionFilter(NavigationManager nm)
|
||||
public ExceptionFilter()
|
||||
{
|
||||
this.nm = nm;
|
||||
}
|
||||
|
||||
public async Task OnExceptionAsync(ExceptionContext context)
|
||||
{
|
||||
if (context.Exception is InvalidOperationException)
|
||||
{
|
||||
nm.NavigateTo("/Login");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 创建一个包含错误信息的对象
|
||||
var errorObject = new
|
||||
|
|
|
|||
Loading…
Reference in New Issue