CloudBuilder.Topshelf/Task/Python/PythonRunTask.cs
owenchen 2c6475b2d5 ow
2026-06-22 17:02:26 +08:00

90 lines
3.6 KiB
C#

using CloudBuilder.AI.Policy;
using CloudBuilder.Core.DatabaseAccessor.Entity;
using CloudBuilder.Core.DependencyInjection.Task;
using CloudBuilder.Topshelf.Python;
using CloudBuilder.Topshelf.Utility;
namespace CloudBuilder.Topshelf.Task
{
//task:PythonRunTask param_name:param_value
public class PythonRunTask : IScheduleTask
{
private readonly IApplicationService service;
public PythonRunTask(IApplicationService service)
{
this.service = service;
}
public void Run(Dictionary<string, string> bodyDict)
{
//Python39Command python39Command = new Python39Command(service);
try
{
//SoVITS soVITS = new SoVITS(python39Command);
//Array voiceArray = Enum.GetValues(typeof(SoVITSTtsVoice));
//foreach (SoVITSTtsVoice voice in voiceArray)
//{
// soVITS.Generate("三更时分,青龙城毫无征兆地被血色浓雾笼罩,雾气带着诡异的幻术气息,城中低阶修士尽数陷入昏睡.", soVITS.Voices[voice], $"F:\\GPT-SoVITS\\gen\\{(int)voice}.mp3");
//}
Array voices = Enum.GetValues(typeof(ChineseTtsVoice));
foreach (ChineseTtsVoice voice in voices)
{
SaveAudioToFileHelper.AudioToFile(voice, 1.0f, "三更时分,青龙城毫无征兆地被血色浓雾笼罩,雾气带着诡异的幻术气息,城中低阶修士尽数陷入昏睡.", $"F:\\GPT-SoVITS\\gen\\{(int)voice}.mp3");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
//python39Command.Dispose();
}
return;
PythonCommand python = new PythonCommand(service);
try
{
Hanlp2 hanlp = new Hanlp2(python);
string text = @"金越大师,听说你前两日派人请这位韩道友聚一下,他却开始闭关了,可有此事的。";
//text = "艳美少妇打了韩立";
//text = "徐先生还具体帮助他确定了把画雄鹰、松鼠和麻雀作为主攻目标。";
text = "银发老者神色一肃的向金越禅师问道。";
//text = "鬼灵门门主一边吩咐着,一边冷冷打量着悬浮在身前的画轴,见其并没有任何异样发生,目光闪动几下。";
text = "二愣子睁大着双眼,直直望着茅草和烂泥糊成的黑屋顶,身上盖着的旧棉被,已呈深黄色,看不出原来的本来面目,还若有若无的散发着淡淡的霉味。";
//List<string> sentiments = hanlp.GetTokFine(text);
//sentiments = hanlp.GetTokCoarse(text);
//string depRoot = hanlp.GetDepRoot(text);
//List<NamedEntity> ners = hanlp.GetHanlpNer(text);
//List<List<MeaningRepresentationParsingEntity>> srls = hanlp.GetHanlpSrl(text);
//List<HanlpConstituencyNode> cons = hanlp.GetHanlpCon(text);
SpeakerAnalysisHelper speakerFeatureLearner = new SpeakerAnalysisHelper();
var person = speakerFeatureLearner.GetPerson(hanlp, text);
text = "韩立闻言,眉头不经意的一皱,想了想后,还是摇摇头说道:";
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
python.Dispose();
}
}
}
}