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