93 lines
3.3 KiB
C#
93 lines
3.3 KiB
C#
using AntDesign;
|
|
using AntDesign.TableModels;
|
|
using FFmpeg.NET.Services;
|
|
using Learn.VideoAnalysis.Controllers.Dto;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.DataProtection.KeyManagement;
|
|
using Microsoft.JSInterop;
|
|
using SqlSugar;
|
|
using System.Linq.Expressions;
|
|
using System.Threading.Tasks;
|
|
using VideoAnalysisCore.AICore.GPT.Dto;
|
|
using VideoAnalysisCore.AICore.SherpaOnnx;
|
|
using VideoAnalysisCore.Common;
|
|
using VideoAnalysisCore.Enum;
|
|
using VideoAnalysisCore.Model;
|
|
using VideoAnalysisCore.Model.Dto;
|
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
|
|
namespace Learn.VideoAnalysis.Components.Pages
|
|
{
|
|
public partial class VideoTaskShow : ComponentBase
|
|
{
|
|
/// <summary>
|
|
/// 任务id
|
|
/// </summary>
|
|
[Parameter]
|
|
public long? taskId { get; set; }
|
|
[Inject] private ConfirmService ComfirmService { get; set; } = default!;
|
|
[Inject] private IHttpContextAccessor HttpContext { get; set; } = default!;
|
|
[Inject] private Repository<VideoTask> taskDB { get; set; } = default!;
|
|
[Inject] private IJSRuntime JSRuntime { get; set; } = default!;
|
|
|
|
private VideoTask nowTask { get; set; } = default!;
|
|
private string videoPath { get; set; } = default!;
|
|
|
|
/// <summary>
|
|
/// 字幕
|
|
/// </summary>
|
|
private SenseVoiceRes[] captionsArr { get; set; } = default!;
|
|
/// <summary>
|
|
/// 分段
|
|
/// </summary>
|
|
private VideoKnowRes[] videoKnows { get; set; } = default!;
|
|
/// <summary>
|
|
/// 在渲染页面之后
|
|
/// </summary>
|
|
/// <param name="firstRender"></param>
|
|
/// <returns></returns>
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
if (firstRender)
|
|
{
|
|
}
|
|
|
|
|
|
}
|
|
public string getF(VideoKnowRes segment)
|
|
{
|
|
var sf = ((int)((segment.StartTime ?? 0) / 60)).ToString().PadLeft(2,'0');
|
|
var sm = ((int)((segment.StartTime ?? 0) % 60)).ToString().PadLeft(2, '0');
|
|
var ef = ((int)((segment.EndTime ?? 0) / 60)).ToString().PadLeft(2, '0');
|
|
var em = ((int)((segment.EndTime ?? 0) % 60)).ToString().PadLeft(2, '0');
|
|
return $"{sf}:{sm} - {ef}: {em}";
|
|
}
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
protected override async void OnInitialized()
|
|
{
|
|
if (this.taskId is null)
|
|
return;
|
|
long taskId = this.taskId.Value;
|
|
nowTask = await taskDB.GetFirstAsync(s => s.Id == taskId);
|
|
if(nowTask is null)
|
|
return;
|
|
captionsArr = RedisExpand.Redis.HMGet<SenseVoiceRes[]>(RedisExpandKey.Task(taskId), "Captions").FirstOrDefault();
|
|
videoKnows = RedisExpand.Redis.HMGet<VideoKnowRes[]>(RedisExpandKey.Task(taskId), "VideoKnows").FirstOrDefault();
|
|
videoPath = AppCommon.GetVideoPath(nowTask.Id.ToString());
|
|
|
|
await JSRuntime.InvokeVoidAsync("setDB", captionsArr,videoKnows, videoPath);
|
|
StateHasChanged();
|
|
}
|
|
|
|
private async Task<bool> Comfirm(string message)
|
|
{
|
|
return await ComfirmService.Show(message, "提示", ConfirmButtons.YesNo, ConfirmIcon.Warning) == ConfirmResult.Yes;
|
|
}
|
|
|
|
}
|
|
|
|
}
|