修复 ioc注入异常
This commit is contained in:
parent
cf44785ae9
commit
a8ec291497
|
|
@ -38,11 +38,11 @@ namespace Learn.VideoAnalysis
|
|||
loggingBuilder.SetMinimumLevel(LogLevel.Warning); // 设置最小日志级别为 Warning
|
||||
});
|
||||
|
||||
//°ó¶¨ appsetting ÅäÖÃ
|
||||
builder.Configuration.AddAppConfig(args);
|
||||
//初始化 插件
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerExpand("AI视频分析");
|
||||
//°ó¶¨ appsetting ÅäÖÃ
|
||||
builder.Configuration.AddAppConfig(args);
|
||||
builder.Services.AddPermissionAuthentication();
|
||||
builder.Services.AddSqlSugarExpand();
|
||||
builder.Services.AddRedisExpand();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
/// <param name="services"></param>
|
||||
public static void AddFunASRNanoExpand(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<SenseVoice>();
|
||||
services.AddSingleton<FunASRNano>();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
|
@ -97,8 +97,9 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
public List<SenseVoiceRes> RunTask(Stream s)
|
||||
{
|
||||
if (s is null) throw new Exception("音频路径 is null");
|
||||
if (OR is null) Init();
|
||||
return serviceProvider.GetRequiredService<SherpaVad>()
|
||||
.TaskHandle(new WaveReader(s), null, SoundHandle, SherpaVadVersion.silero_vad_v5);
|
||||
.TaskHandle(new WaveReader(s), null, SoundHandle, SherpaVadVersion.ten_vad_324);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取语音字幕
|
||||
|
|
@ -110,8 +111,9 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
var filePath = Path.Combine(task.LocalPath(), "task.wav");
|
||||
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
|
||||
throw new Exception("task 音频路径未找到");
|
||||
if (OR is null) Init();
|
||||
serviceProvider.GetRequiredService<SherpaVad>()
|
||||
.TaskHandle(new WaveReader(filePath), null, SoundHandle, SherpaVadVersion.silero_vad_v5);
|
||||
.TaskHandle(new WaveReader(filePath), null, SoundHandle, SherpaVadVersion.ten_vad_324);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,9 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
/// <returns></returns>
|
||||
public List<SenseVoiceRes> RunTask(Stream s)
|
||||
{
|
||||
|
||||
if (s is null) throw new Exception("音频路径 is null");
|
||||
if (OR is null) Init();
|
||||
return serviceProvider.GetRequiredService<SherpaVad>()
|
||||
.TaskHandle(new WaveReader(s), null, SoundHandle, SherpaVadVersion.silero_vad_v5);
|
||||
}
|
||||
|
|
@ -113,6 +115,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
|||
var filePath = Path.Combine(task.LocalPath(), "task.wav");
|
||||
if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath))
|
||||
throw new Exception("task 音频路径未找到");
|
||||
if (OR is null) Init();
|
||||
serviceProvider.GetRequiredService<SherpaVad>()
|
||||
.TaskHandle(new WaveReader(filePath), null, SoundHandle, SherpaVadVersion.silero_vad_v5);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,10 +37,12 @@ namespace VideoAnalysisCore.Controllers
|
|||
|
||||
readonly RedisManager redisManager;
|
||||
public readonly SenseVoice senseVoice;
|
||||
public readonly FunASRNano funASRNano;
|
||||
|
||||
private readonly IMapper mp;
|
||||
public VideoTaskController(Repository<VideoTask> baseService, RedisManager redisManager,
|
||||
Repository<VideoQuestion> videoQuestionDB,
|
||||
Repository<VideoQuestionKonw> videoQuestionKonwDB, Repository<VideoKonwPoint> videoKonwPointDB, SenseVoice senseVoice, IMapper mp, Repository<TaskLog> taskLogDB) : base(baseService)
|
||||
Repository<VideoQuestionKonw> videoQuestionKonwDB, Repository<VideoKonwPoint> videoKonwPointDB, SenseVoice senseVoice, IMapper mp, Repository<TaskLog> taskLogDB, FunASRNano funASRNano) : base(baseService)
|
||||
{
|
||||
this.baseService = baseService;
|
||||
this.redisManager = redisManager;
|
||||
|
|
@ -50,6 +52,7 @@ namespace VideoAnalysisCore.Controllers
|
|||
this.senseVoice = senseVoice;
|
||||
this.mp = mp;
|
||||
this.taskLogDB = taskLogDB;
|
||||
this.funASRNano = funASRNano;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -147,6 +150,16 @@ namespace VideoAnalysisCore.Controllers
|
|||
{
|
||||
using var s = file.OpenReadStream();
|
||||
var res = senseVoice.RunTask(s);
|
||||
s.Position = 0;
|
||||
var res1 = funASRNano.RunTask(s);
|
||||
|
||||
for (int i = 0; i < res.Count(); i++)
|
||||
{
|
||||
Console.WriteLine($"第{res[i].Start}秒");
|
||||
Console.WriteLine($"ssv=> {res[i].Text}");
|
||||
Console.WriteLine($"fun=> {res1[i].Text}");
|
||||
Console.WriteLine();
|
||||
}
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue