From de1cdcf32cd6a63145592018f61630d782169949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=82=A5=E7=BE=8A?= <1048382248@qq.com> Date: Tue, 13 Jan 2026 15:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=89=80=E5=B1=9E=E4=BA=91=E6=A0=A1id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VideoAnalysis/Expand/AuthorizeExpand.cs | 4 ++ VideoAnalysis/Program.cs | 5 ++- .../AICore/GPT/GTP_Analysis_1.cs | 1 + .../AICore/SherpaOnnx/SenseVoice.cs | 44 ++++++++++++++++--- VideoAnalysisCore/Controllers/Dto/ApiDto.cs | 4 ++ .../Controllers/LJZK_Controller.cs | 4 +- VideoAnalysisCore/Model/NodePackageInfo.cs | 6 +++ VideoAnalysisCore/Model/VideoKonwPoint.cs | 6 +++ VideoAnalysisCore/Model/VideoTask.cs | 6 +++ VideoAnalysisCore/VideoAnalysisCore.csproj | 2 +- 10 files changed, 73 insertions(+), 9 deletions(-) diff --git a/VideoAnalysis/Expand/AuthorizeExpand.cs b/VideoAnalysis/Expand/AuthorizeExpand.cs index ddcfe21..b2e1b54 100644 --- a/VideoAnalysis/Expand/AuthorizeExpand.cs +++ b/VideoAnalysis/Expand/AuthorizeExpand.cs @@ -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; diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index c939176..bddd625 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -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(); // 清除默认的日志提供程序 diff --git a/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs b/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs index 8445c74..8499e0e 100644 --- a/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs +++ b/VideoAnalysisCore/AICore/GPT/GTP_Analysis_1.cs @@ -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() }); }).ToList(); diff --git a/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs b/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs index 2f177a1..199534c 100644 --- a/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs +++ b/VideoAnalysisCore/AICore/SherpaOnnx/SenseVoice.cs @@ -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 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)) { diff --git a/VideoAnalysisCore/Controllers/Dto/ApiDto.cs b/VideoAnalysisCore/Controllers/Dto/ApiDto.cs index 7a64863..f35f3d9 100644 --- a/VideoAnalysisCore/Controllers/Dto/ApiDto.cs +++ b/VideoAnalysisCore/Controllers/Dto/ApiDto.cs @@ -124,6 +124,10 @@ namespace VideoAnalysisCore.Controllers.Dto /// 瀛︾缃戠殑鏁欐潗鐗堟湰Id /// public long TextBookVersionId { get; set; } + /// + /// 鐢ㄦ埛涓績鐨勪簯鏍d + /// + public long? UserCenterCloudSchoolId { get; set; } /// /// 鏁欒偛闃舵 diff --git a/VideoAnalysisCore/Controllers/LJZK_Controller.cs b/VideoAnalysisCore/Controllers/LJZK_Controller.cs index 42c382a..cf99215 100644 --- a/VideoAnalysisCore/Controllers/LJZK_Controller.cs +++ b/VideoAnalysisCore/Controllers/LJZK_Controller.cs @@ -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); diff --git a/VideoAnalysisCore/Model/NodePackageInfo.cs b/VideoAnalysisCore/Model/NodePackageInfo.cs index faa78ed..568a566 100644 --- a/VideoAnalysisCore/Model/NodePackageInfo.cs +++ b/VideoAnalysisCore/Model/NodePackageInfo.cs @@ -87,5 +87,11 @@ namespace VideoAnalysisCore.Model /// 鍥炶皟娣诲姞鍒癏eaders /// public string HostIP { get; set; } + /// + /// 瑙嗛鎵灞炰簯鏍D + /// 鐢ㄦ埛涓績鐨勪簯鏍d + /// + [SugarColumn(IsNullable = true)] + public long? CloudSchoolId { get; set; } } } diff --git a/VideoAnalysisCore/Model/VideoKonwPoint.cs b/VideoAnalysisCore/Model/VideoKonwPoint.cs index f8a1b46..0b4a41c 100644 --- a/VideoAnalysisCore/Model/VideoKonwPoint.cs +++ b/VideoAnalysisCore/Model/VideoKonwPoint.cs @@ -73,5 +73,11 @@ namespace VideoAnalysisCore.Model /// [SugarColumn(IsIgnore = true)] public virtual StageEnum? Stage { get; set; } + /// + /// 瑙嗛鎵灞炰簯鏍D + /// 鐢ㄦ埛涓績鐨勪簯鏍d + /// + [SugarColumn(IsNullable = true)] + public long? CloudSchoolId { get; set; } } } diff --git a/VideoAnalysisCore/Model/VideoTask.cs b/VideoAnalysisCore/Model/VideoTask.cs index 2fa77c6..127e7ba 100644 --- a/VideoAnalysisCore/Model/VideoTask.cs +++ b/VideoAnalysisCore/Model/VideoTask.cs @@ -138,6 +138,12 @@ namespace VideoAnalysisCore.Model /// [SugarColumn(IsNullable = true)] public string? Sections { get; set; } + /// + /// 瑙嗛鎵灞炰簯鏍D + /// 鐢ㄦ埛涓績鐨勪簯鏍d + /// + [SugarColumn(IsNullable = true)] + public long? CloudSchoolId { get; set; } } } diff --git a/VideoAnalysisCore/VideoAnalysisCore.csproj b/VideoAnalysisCore/VideoAnalysisCore.csproj index 7af44fc..d7b668b 100644 --- a/VideoAnalysisCore/VideoAnalysisCore.csproj +++ b/VideoAnalysisCore/VideoAnalysisCore.csproj @@ -71,7 +71,7 @@ - +