using SqlSugar;
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Text.Json;
using VideoAnalysisCore.AICore.ChatGPT.Dto;
using VideoAnalysisCore.AICore.SherpaOnnx;
using VideoAnalysisCore.AICore.Whisper;
using VideoAnalysisCore.Enum;
using Whisper.net;
namespace VideoAnalysisCore.Model
{
///
/// 视频任务模型
///
[SugarTable("videotask")]
public class VideoTask
{
///
/// 任务id
/// 视频音频文件地址都使用taskID能获取
///
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long Id { get; set; }
///
/// 媒体路径
///
public string MediaUrl { get; set; } = string.Empty;
///
/// 下载后本地媒体目录
///
public string LocalMediaPath { get; set; } = string.Empty;
///
/// 上一次执行的枚举
///
public RedisChannelEnum LastEnum { get; set; }
///
/// ApiKey
///
public string ApiToken { get; set; } = string.Empty;
///
/// 请求来自哪个ip地址
///
public string ComeFrom { get; set; } = string.Empty;
///
/// 自定义值 任务完成后附带通知
///
[SugarColumn(Length = 500)]
public string Tag { get; set; }
///
///回调Api地址
///
[SugarColumn(Length = 500)]
public string CallBackUrl { get; set; }
///
/// 字幕缓存
///
[SugarColumn(ColumnName = "Captions", ColumnDataType = "longtext", IsNullable = true)]
public string _Captions { get; set; } = "[]";
///
/// 字幕缓存
///
[SugarColumn(IsIgnore = true)]
public SenseVoiceRes[]? Captions
{
get=> JsonSerializer.Deserialize(_Captions ?? "[]");
set => _Captions = JsonSerializer.Serialize(value);
}
///
/// 说话人日志解析缓存
///
[SugarColumn(ColumnName = "Speaker", ColumnDataType = "longtext", IsNullable = true)]
public string _Speaker { get; set; } = "[]";
///
/// 说话人日志解析缓存
///
[SugarColumn(IsIgnore = true)]
public OfflineSpeakerRes[]? Speaker
{
get => JsonSerializer.Deserialize(_Speaker ?? "[]");
set => _Speaker = JsonSerializer.Serialize(value);
}
///
/// Chat模型分析缓存
///
[SugarColumn(ColumnName = "ChatAnalysis", ColumnDataType = "longtext", IsNullable = true)]
public string _ChatAnalysis { get; set; } = "{}";
///
/// Chat模型分析缓存
///
[SugarColumn(IsIgnore = true)]
public CallGPTRes? ChatAnalysis
{
get => JsonSerializer.Deserialize(_ChatAnalysis ?? "{}");
set => _ChatAnalysis = JsonSerializer.Serialize(value);
}
///
/// 消耗token
///
public int TotalTokens { get; set; }
///
/// 错误信息
///
[SugarColumn(ColumnDataType = "text", IsNullable = true)]
public string? ErrorMessage { get; set; }
///
/// 创建时间
///
public DateTime CreateTime { get; set; } = DateTime.Now;
///
/// 开始时间轴
///
[SugarColumn(ColumnDataType = "varchar", Length = 255)]
public string StartTime { get; set; } ="{}";
///
/// 开始时间轴
/// 逻辑字段
///
[SugarColumn(IsIgnore = true)]
public Dictionary StartTimeDic
{
get
{
return JsonSerializer.Deserialize>(StartTime??"{}")
??new Dictionary();
}
set
{
StartTime = JsonSerializer.Serialize(value);
}
}
}
}