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