parent
a2c9831a0a
commit
d3cf043e09
|
|
@ -8,7 +8,9 @@
|
||||||
@using VideoAnalysisCore.Model.Dto
|
@using VideoAnalysisCore.Model.Dto
|
||||||
@using VideoAnalysisCore.Enum
|
@using VideoAnalysisCore.Enum
|
||||||
|
|
||||||
<Table @ref="_table" Loading="tableLoading" TItem="VideoTaskDto" ScrollY="600px" PageSize="10" Total="_total" DataSource="_dataSource" @bind-SelectedRows="_selectedRows" OnChange="OnChange"
|
<Table @ref="_table" Loading="tableLoading" TItem="VideoTaskDto" ScrollY="600px" PageSize="10" Total="_total" DataSource="_dataSource"
|
||||||
|
OnRowClick="(r)=>r.Expanded = !r.Expanded"
|
||||||
|
@bind-SelectedRows="_selectedRows" OnChange="OnChange"
|
||||||
OnExpand="OnExpand">
|
OnExpand="OnExpand">
|
||||||
<TitleTemplate>
|
<TitleTemplate>
|
||||||
<Flex Justify="end" Gap="10">
|
<Flex Justify="end" Gap="10">
|
||||||
|
|
@ -36,7 +38,7 @@
|
||||||
<DescriptionsItem Title="操作" Span="2">
|
<DescriptionsItem Title="操作" Span="2">
|
||||||
<Button Type="@ButtonType.Primary"
|
<Button Type="@ButtonType.Primary"
|
||||||
Loading="rowRestartLoading"
|
Loading="rowRestartLoading"
|
||||||
OnClick="()=>RowRestart(rowData)">
|
OnClick="()=>RowRload(rowData)">
|
||||||
刷新数据
|
刷新数据
|
||||||
</Button>
|
</Button>
|
||||||
<Button Type="@ButtonType.Primary" Danger @onclick="() => ReStartClick(rowData.Data)">
|
<Button Type="@ButtonType.Primary" Danger @onclick="() => ReStartClick(rowData.Data)">
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,8 @@ namespace Learn.VideoAnalysis.Components.Pages
|
||||||
private bool rowRestartLoading = false;
|
private bool rowRestartLoading = false;
|
||||||
private VideoTaskDto reStartTask ;
|
private VideoTaskDto reStartTask ;
|
||||||
|
|
||||||
TextValue[] SelectDataSource = Enum.GetValues(typeof(RedisChannelEnum))
|
static TextValue[] SelectDataSource =
|
||||||
|
Enum.GetValues(typeof(RedisChannelEnum))
|
||||||
.Cast<RedisChannelEnum>()
|
.Cast<RedisChannelEnum>()
|
||||||
.Select(s => new TextValue(s.ToString(), (int)s))
|
.Select(s => new TextValue(s.ToString(), (int)s))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
@ -106,7 +107,11 @@ namespace Learn.VideoAnalysis.Components.Pages
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
|
|
||||||
}
|
}
|
||||||
public void RowRestart(RowData<VideoTaskDto> rowData)
|
/// <summary>
|
||||||
|
/// 刷新数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rowData"></param>
|
||||||
|
public void RowRload(RowData<VideoTaskDto> rowData)
|
||||||
{
|
{
|
||||||
rowRestartLoading = true;
|
rowRestartLoading = true;
|
||||||
var item = rowData.Data;
|
var item = rowData.Data;
|
||||||
|
|
@ -145,14 +150,11 @@ namespace Learn.VideoAnalysis.Components.Pages
|
||||||
}
|
}
|
||||||
private int RowSTIndex(RowData<VideoTaskDto> rowData)
|
private int RowSTIndex(RowData<VideoTaskDto> rowData)
|
||||||
{
|
{
|
||||||
var dic = rowData.Data.StartTimeDic;
|
return (int)rowData.Data.LastEnum;
|
||||||
if (dic is null)
|
|
||||||
return 0;
|
|
||||||
return (int)dic.LastOrDefault().Key;
|
|
||||||
}
|
}
|
||||||
private void OnExpand(RowData<VideoTaskDto> rowData)
|
private void OnExpand(RowData<VideoTaskDto> rowData)
|
||||||
{
|
{
|
||||||
RowRestart(rowData);
|
RowRload(rowData);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在渲染页面之后
|
/// 在渲染页面之后
|
||||||
|
|
|
||||||
|
|
@ -157,12 +157,15 @@ namespace VideoAnalysisCore.AICore.ChatGPT.KIMI
|
||||||
{
|
{
|
||||||
if (item is null)
|
if (item is null)
|
||||||
continue;
|
continue;
|
||||||
|
var r = item.Content.ToEnum<TimeBaseTypeEnum>();
|
||||||
|
if (r is null)
|
||||||
|
continue;
|
||||||
var arr = gptRes.TimeBase?
|
var arr = gptRes.TimeBase?
|
||||||
.Where(s => s.Start >= item.Start && s.End <= item.End);
|
.Where(s => s.Start >= item.Start && s.End <= item.End);
|
||||||
if (arr is null)
|
if (arr is null)
|
||||||
continue;
|
continue;
|
||||||
foreach (var s in arr)
|
foreach (var s in arr)
|
||||||
s.TimeBaseType = item.Content.ToEnum<TimeBaseTypeEnum>();
|
s.TimeBaseType = r;
|
||||||
}
|
}
|
||||||
var totalTokens = chatResp?.usage.total_tokens ?? 0;
|
var totalTokens = chatResp?.usage.total_tokens ?? 0;
|
||||||
if (totalTokens > 1)
|
if (totalTokens > 1)
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,7 @@ namespace VideoAnalysisCore.AICore.ChatGPT.KIMI
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var client = _httpClientFactory.CreateClient();
|
var client = _httpClientFactory.CreateClient();
|
||||||
|
client.Timeout = TimeSpan.FromSeconds(60 * 20);//超时时间20分钟
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ApiKey);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ApiKey);
|
||||||
var request = ToHttpRequest(path);
|
var request = ToHttpRequest(path);
|
||||||
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
|
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
||||||
public class SenseVoice
|
public class SenseVoice
|
||||||
{
|
{
|
||||||
static OfflineRecognizer OR =default!;
|
static OfflineRecognizer OR =default!;
|
||||||
static VoiceActivityDetector VAD = default!;
|
//static VoiceActivityDetector VAD = default!;
|
||||||
static VadModelConfig VADModelConfig = default!;
|
static VadModelConfig VADModelConfig = default!;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化 SenseVoice
|
/// 初始化 SenseVoice
|
||||||
|
|
@ -71,8 +71,6 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
||||||
VADModelConfig = new VadModelConfig();
|
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, "sherpa-onnx-sense-voice-24-07-17", "silero_vad.onnx");
|
||||||
VADModelConfig.Debug = 0;
|
VADModelConfig.Debug = 0;
|
||||||
//缓冲区大小
|
|
||||||
VAD = new VoiceActivityDetector(VADModelConfig, 60);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -94,6 +92,9 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
||||||
int numIter = numSamples / windowSize;
|
int numIter = numSamples / windowSize;
|
||||||
var totalSecond = numSamples / (float)sampleRate;
|
var totalSecond = numSamples / (float)sampleRate;
|
||||||
var res = new List<SenseVoiceRes>(500);
|
var res = new List<SenseVoiceRes>(500);
|
||||||
|
|
||||||
|
//缓冲区大小
|
||||||
|
var VAD = new VoiceActivityDetector(VADModelConfig, 60);
|
||||||
//var VAD = new VoiceActivityDetector(VADModelConfig, 60);
|
//var VAD = new VoiceActivityDetector(VADModelConfig, 60);
|
||||||
for (int i = 0; i != numIter; ++i)
|
for (int i = 0; i != numIter; ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -173,7 +174,7 @@ namespace VideoAnalysisCore.AICore.SherpaOnnx
|
||||||
int numIter = numSamples / windowSize;
|
int numIter = numSamples / windowSize;
|
||||||
var totalSecond = numSamples / (float)sampleRate;
|
var totalSecond = numSamples / (float)sampleRate;
|
||||||
var res = new List<SenseVoiceRes>(500);
|
var res = new List<SenseVoiceRes>(500);
|
||||||
//var VAD = new VoiceActivityDetector(VADModelConfig, 60);
|
var VAD = new VoiceActivityDetector(VADModelConfig, 60);
|
||||||
for (int i = 0; i != numIter; ++i)
|
for (int i = 0; i != numIter; ++i)
|
||||||
{
|
{
|
||||||
int start = i * windowSize;
|
int start = i * windowSize;
|
||||||
|
|
|
||||||
|
|
@ -207,9 +207,16 @@ namespace VideoAnalysisCore.Common
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T? ToEnum<T>(this object data) where T : struct, System.Enum
|
public static T? ToEnum<T>(this object data) where T : struct, System.Enum
|
||||||
{
|
{
|
||||||
if (data is null || string.IsNullOrEmpty(data?.ToString()))
|
try
|
||||||
|
{
|
||||||
|
if (data is null || string.IsNullOrEmpty(data?.ToString()))
|
||||||
|
return null;
|
||||||
|
return System.Enum.Parse<T>(data.ToString());
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
return System.Enum.Parse<T>(data.ToString());
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 转化本地缓存目录
|
/// 转化本地缓存目录
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace VideoAnalysisCore.Common
|
||||||
Redis.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
|
Redis.Deserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
Task.Delay(1000 * 5);
|
Task.Delay(1000 * 10);
|
||||||
InitChannel();
|
InitChannel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue