diff --git a/Lib/CloudBuilder.AI.Service.dll b/Lib/CloudBuilder.AI.Service.dll index 11627aa..78b69b9 100644 Binary files a/Lib/CloudBuilder.AI.Service.dll and b/Lib/CloudBuilder.AI.Service.dll differ diff --git a/Lib/CloudBuilder.AI.dll b/Lib/CloudBuilder.AI.dll index 63b5b5a..799fc9a 100644 Binary files a/Lib/CloudBuilder.AI.dll and b/Lib/CloudBuilder.AI.dll differ diff --git a/Python/SoVITS.cs b/Python/SoVITS.cs index df643e2..b5d3506 100644 --- a/Python/SoVITS.cs +++ b/Python/SoVITS.cs @@ -22,10 +22,19 @@ namespace CloudBuilder.Topshelf.Python if (!File.Exists(file)) return; string init = File.ReadAllText(file, Encoding.UTF8); - + File.AppendAllText("log.txt", "SoVITS:" + file + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); using (Py.GIL()) { - python.Exec(init); + try + { + python.Exec(init); + } + catch (Exception ex) + { + File.AppendAllText("log.txt", "SoVITS-Exec:" + ex.Message + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + } + + File.AppendAllText("log.txt", "SoVITS-Exec:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); } } diff --git a/Task/TTS/SoVITSTtsTask.cs b/Task/TTS/SoVITSTtsTask.cs index 1dbc017..787375b 100644 --- a/Task/TTS/SoVITSTtsTask.cs +++ b/Task/TTS/SoVITSTtsTask.cs @@ -28,13 +28,14 @@ namespace CloudBuilder.Topshelf.Task.TTS public SoVITSTtsTask(IApplicationService service) { + File.AppendAllText("log.txt", "SoVITSTtsTask:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); this.service = service; } public void Run(Dictionary bodyDict) { + File.AppendAllText("log.txt", "Run:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); ConsoleOutput.HideStdError(); - IRepository repository = service.GetRepository>(); string bookId = string.Empty; @@ -58,9 +59,8 @@ namespace CloudBuilder.Topshelf.Task.TTS && (string.IsNullOrEmpty(from_chapter_id) || x.ChapterId >= Convert.ToInt32(from_chapter_id)) && (string.IsNullOrEmpty(to_chapter_id) || x.ChapterId <= Convert.ToInt32(to_chapter_id) )).OrderBy(x => x.ChapterId).ThenBy(x => x.ParagraphId).ThenBy(x => x.SentenceIndex).ToArray(); - if (ents == null || ents.Length == 0) return; - + File.AppendAllText("log.txt", "SoVITSTtsVoiceRandom:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); string save_path = string.Empty, text = string.Empty, voice = SoVITSTtsVoiceRandom.GetRandomYoungFemale().ToString(), actor = string.Empty, actor_voice = SoVITSTtsVoiceRandom.GetRandomYoungMale().ToString(); if (bodyDict.ContainsKey("actor")) actor = bodyDict["actor"]; @@ -78,18 +78,23 @@ namespace CloudBuilder.Topshelf.Task.TTS if (bodyDict.ContainsKey("speed")) speed = Convert.ToSingle(bodyDict["speed"]); - + File.AppendAllText("log.txt", "GenerateAndMergeChapterAudio:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); GenerateAndMergeChapterAudio(ents, speed, actor, actor_voice, voice, save_path); } public void GenerateAndMergeChapterAudio(AiSentenceViewEntity[] ents, float speed, string actor, string actor_voice, string mainVoice, string save_path) { IRepository repositoryAiBookPersonEntity = service.GetRepository>(); + File.AppendAllText("log.txt", "BookId:" + ents[0].BookId + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); + AiBookPersonEntity[] bps = repositoryAiBookPersonEntity.DetachedEntities.Where(x => x.BookId == ents[0].BookId).ToArray(); + File.AppendAllText("log.txt", "repositoryAiBookPersonEntity:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); Python39Command python39Command = new Python39Command(service); + File.AppendAllText("log.txt", "Python39Command:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); SoVITS soVITS = new SoVITS(python39Command); + File.AppendAllText("log.txt", "SoVITS:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); // 1. 按 BookId + ChapterId 分组(关键!) var chapterGroups = ents .Where(ent => ent.Content.Any(c => c >= 0x4E00 && c <= 0x9FFF)) // 只保留含中文的句子 @@ -179,6 +184,7 @@ namespace CloudBuilder.Topshelf.Task.TTS string fileName = string.Format("{0}_{1}_{2}_{3}.mp3", ent.BookId, ent.ChapterId, ent.ParagraphId, ent.SentenceId); string filePath = Path.Combine(save_path, fileName); + File.AppendAllText("log.txt", "Generate:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n"); // 生成音频 soVITS.Generate(ent.Content, soVITS.Voices[EnumHelper.ToEnum(voice)], filePath);