新增 视频所属云校id

This commit is contained in:
小肥羊 2026-01-13 15:11:50 +08:00
parent ba00c75a36
commit de1cdcf32c
10 changed files with 73 additions and 9 deletions

View File

@ -53,7 +53,11 @@ namespace Learn.VideoAnalysis.Expand
{
context.HandleResponse();
if (context.Response.StatusCode == 403)
{
var data1 = new { Code = 403, Message = context.Error + context.AuthenticateFailure?.Message };
context.Response.WriteAsync(data1.ToJson());
return Task.CompletedTask;
}
context.Response.Clear();
context.Response.ContentType = "application/json";
context.Response.StatusCode = 401;

View File

@ -27,7 +27,10 @@ namespace Learn.VideoAnalysis
{
var builder = WebApplication.CreateBuilder(args);
//设置接口请求体最大100m
builder.WebHost.ConfigureKestrel(serverOptions => {
serverOptions.Limits.MaxRequestBodySize = 100_000_000; // 100MB
});
builder.Services.AddLogging(loggingBuilder =>
{
loggingBuilder.ClearProviders(); // 清除默认的日志提供程序

View File

@ -129,6 +129,7 @@ namespace VideoAnalysisCore.AICore.GPT.DeepSeek
KnowPointId = knowDic[x].ToString(),
TagId = taskInfo.TagId,
VideoTaskId = taskInfo.Id,
CloudSchoolId = taskInfo.CloudSchoolId,
Stage = s?.Stage?.ToEnum<StageEnum>()
});
}).ToList();

View File

@ -32,9 +32,9 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
}
public class SenseVoice
{
const string TransducerStr = "sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20";
//const string TransducerStr = "sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20";
static OfflineRecognizer OR = default!;
//static VoiceActivityDetector VAD = default!;
static OfflineRecognizer OR_old = default!;
static VadModelConfig VADModelConfig = default!;
public Repository<VideoTask> videoTaskDB { get; set; }
@ -59,10 +59,12 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
config.FeatConfig.SampleRate = 16000;
//用于训练模型的特征维度
config.FeatConfig.FeatureDim = 80;
//Path to tokens.txt
config.ModelConfig.Tokens = Path.Combine(AppCommon.AIModelFile, "sherpa-onnx-sense-voice-24-07-17", "tokens.txt");
// Path to tokens.txt
var AIModelVersion_270717 = "sherpa-onnx-sense-voice-24-07-17";
var AIModelVersion_251217 = "sherpa-onnx-sense-voice-funasr-nano-2025-12-17";
config.ModelConfig.Tokens = Path.Combine(AppCommon.AIModelFile, AIModelVersion_251217, "tokens.txt");
//SenseVoice 模型
config.ModelConfig.SenseVoice.Model = Path.Combine(AppCommon.AIModelFile, "sherpa-onnx-sense-voice-24-07-17", "model.onnx");
config.ModelConfig.SenseVoice.Model = Path.Combine(AppCommon.AIModelFile, AIModelVersion_251217, "model.onnx");
//1 使用逆文本规范化处理感官语音 [控制标点符号生成]。
config.ModelConfig.SenseVoice.UseInverseTextNormalization = 1;
//反转文本规范化规则 fst 的路径
@ -116,8 +118,26 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
OR = new OfflineRecognizer(config);
OfflineRecognizerConfig oldConfig = new OfflineRecognizerConfig();
//采样率
oldConfig.FeatConfig.SampleRate = 16000;
oldConfig.FeatConfig.FeatureDim = 80;
oldConfig.ModelConfig.Tokens = Path.Combine(AppCommon.AIModelFile, AIModelVersion_270717, "tokens.txt");
oldConfig.ModelConfig.SenseVoice.Model = Path.Combine(AppCommon.AIModelFile, AIModelVersion_270717, "model.onnx");
oldConfig.ModelConfig.SenseVoice.UseInverseTextNormalization = 1;
//反转文本规范化规则 fst 的路径
//config.RuleFsts = Path.Combine(AppCommon.AIModelFile, "itn_subject_sx.fst");
oldConfig.ModelConfig.SenseVoice.Language = "zh";
//模型类型
oldConfig.ModelConfig.ModelType = string.Empty;
oldConfig.ModelConfig.NumThreads = numThreads;
oldConfig.ModelConfig.Provider = "cpu";
OR_old = new OfflineRecognizer(oldConfig);
VADModelConfig = new VadModelConfig();
VADModelConfig.SileroVad.Model = Path.Combine(AppCommon.AIModelFile, "sherpa-onnx-sense-voice-24-07-17", "silero_vad.onnx");
VADModelConfig.SileroVad.Model = Path.Combine(AppCommon.AIModelFile, AIModelVersion_270717, "silero_vad.onnx");
VADModelConfig.Debug = 0;
}
@ -226,6 +246,18 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
using var stream = OR.CreateStream();
stream.AcceptWaveform(sampleRate, segment.Samples);
OR.Decode(stream);
//old
using var stream1 = OR_old.CreateStream();
stream1.AcceptWaveform(sampleRate, segment.Samples);
OR.Decode(stream1);
if (stream.Result.Text != stream1.Result.Text)
{
Console.WriteLine("=>" + (float)Math.Round(startTime, 2, MidpointRounding.AwayFromZero));
Console.WriteLine("新=>" + stream.Result.Text);
Console.WriteLine("旧=>" + stream1.Result.Text);
}
Console.WriteLine();
double? resP =null;
if (!string.IsNullOrEmpty(stream.Result.Text))
{

View File

@ -124,6 +124,10 @@ namespace VideoAnalysisCore.Controllers.Dto
/// 学科网的教材版本Id
/// </summary>
public long TextBookVersionId { get; set; }
/// <summary>
/// 用户中心的云校id
/// </summary>
public long? UserCenterCloudSchoolId { get; set; }
/// <summary>
/// 教育阶段

View File

@ -110,6 +110,7 @@ namespace VideoAnalysisCore.Controllers
VideoUrl = s.VideoUrl,
CourseType = s.CourseType,
CallBackUrl = s.CallBackUrl,
CloudSchoolId =s.UserCenterCloudSchoolId,
Area = s.Area,
HostIP = s.HostIP,
};
@ -129,7 +130,8 @@ namespace VideoAnalysisCore.Controllers
MediaUrl = s.VideoUrl,
PPTVideoCode = pptCode,
PPTVideoUrl = pptUrl,
VideoType = s.CourseType
VideoType = s.CourseType,
CloudSchoolId = s.UserCenterCloudSchoolId,
});
}
await nodePackageInfoDB.InsertRangeAsync(nodePackages);

View File

@ -87,5 +87,11 @@ namespace VideoAnalysisCore.Model
/// <para>回调添加到Headers</para>
/// </summary>
public string HostIP { get; set; }
/// <summary>
/// 视频所属云校ID
/// <para><see cref="UserCenter.Model.CloudSchool"/> 用户中心的云校id</para>
/// </summary>
[SugarColumn(IsNullable = true)]
public long? CloudSchoolId { get; set; }
}
}

View File

@ -73,5 +73,11 @@ namespace VideoAnalysisCore.Model
/// </summary>
[SugarColumn(IsIgnore = true)]
public virtual StageEnum? Stage { get; set; }
/// <summary>
/// 视频所属云校ID
/// <para><see cref="UserCenter.Model.CloudSchool"/> 用户中心的云校id</para>
/// </summary>
[SugarColumn(IsNullable = true)]
public long? CloudSchoolId { get; set; }
}
}

View File

@ -138,6 +138,12 @@ namespace VideoAnalysisCore.Model
/// </summary>
[SugarColumn(IsNullable = true)]
public string? Sections { get; set; }
/// <summary>
/// 视频所属云校ID
/// <para><see cref="UserCenter.Model.CloudSchool"/> 用户中心的云校id</para>
/// </summary>
[SugarColumn(IsNullable = true)]
public long? CloudSchoolId { get; set; }
}
}

View File

@ -71,7 +71,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="org.k2fsa.sherpa.onnx" Version="1.10.32" />
<PackageReference Include="org.k2fsa.sherpa.onnx" Version="1.12.20" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.205" />