This commit is contained in:
owenchen 2026-06-24 08:30:57 +08:00
parent 7aad7805fd
commit 7eb017d8ee
2 changed files with 32 additions and 6 deletions

View File

@ -283,17 +283,29 @@ namespace CloudBuilder.AI.Service
return new FileStreamResult(stream, contentType) { FileDownloadName = fileDownloadName }; return new FileStreamResult(stream, contentType) { FileDownloadName = fileDownloadName };
} }
//[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
//public void GenerateMp3(AiChapterEntity[] chapters)
//{
// string save_path = Path.Combine(service.Configuration["FileServiceSettings:BackupDmsFileDirectory"], @"voice");
// foreach (AiChapterEntity sentence in chapters)
// {
// string param = PackTtsParameters(save_path, sentence.BookId, sentence.ChapterId.ToString());
// RunMyProcessAsync(service.Configuration["CloudBuilder.Topshelf:Path"], param);
// }
//}
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)] [PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public void GenerateMp3(AiChapterEntity[] chapters) public void GenerateMp3(AiChapterEntity[] chapters)
{ {
string save_path = Path.Combine(service.Configuration["FileServiceSettings:BackupDmsFileDirectory"], @"voice"); string save_path = Path.Combine(service.Configuration["FileServiceSettings:BackupDmsFileDirectory"], @"voice");
foreach (AiChapterEntity sentence in chapters) foreach (AiChapterEntity sentence in chapters)
{ {
string param = PackTtsParameters(save_path, sentence.BookId, sentence.ChapterId.ToString()); string param = PackTtsParameters(ChineseTtsVoice.Sherpa2.ToString(), save_path, sentence.BookId, sentence.ChapterId.ToString());
RunMyProcessAsync(service.Configuration["CloudBuilder.Topshelf:Path"], param); RunMyProcess(service.Configuration["CloudBuilder.Topshelf:Path"], param);
} }
} }
[PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)] [PermissionOperate(name: AIPermissionPolicy.AiBook, operate: Operate.Find)]
public void GenerateMp3ByBookId(string bookId) public void GenerateMp3ByBookId(string bookId)
{ {
@ -304,8 +316,8 @@ namespace CloudBuilder.AI.Service
string save_path = Path.Combine(service.Configuration["FileServiceSettings:BackupDmsFileDirectory"], @"voice"); string save_path = Path.Combine(service.Configuration["FileServiceSettings:BackupDmsFileDirectory"], @"voice");
foreach (AiChapterEntity sentence in chapters) foreach (AiChapterEntity sentence in chapters)
{ {
string param = PackTtsParameters(save_path, sentence.BookId, sentence.ChapterId.ToString()); string param = PackTtsParameters(ChineseTtsVoice.Sherpa2.ToString(), save_path, sentence.BookId, sentence.ChapterId.ToString());
RunMyProcessAsync(service.Configuration["CloudBuilder.Topshelf:Path"], param); RunMyProcess(service.Configuration["CloudBuilder.Topshelf:Path"], param);
} }
} }
@ -346,7 +358,21 @@ namespace CloudBuilder.AI.Service
return para.ToArray().ToDelimiteredList(' '); return para.ToArray().ToDelimiteredList(' ');
} }
private string PackTtsParameters(string save_path, string bookId, string chapterId) private string PackTtsParameters(string voice, string save_path, string bookId, string chapterId)
{
//task:TtsTask book_id:B000008 chapter_id:3 speed:1 voice:Sherpa2 actor:韩立 actor_voice:Sherpa1 save_path:D:\\Net8\\FileServer\\Backup\\DmsFile\\voice
List<string> para = new List<string>();
para.Add("task:" + "TtsTask");
para.Add("book_id:" + bookId);
para.Add("chapter_id:" + chapterId);
para.Add("voice:" + voice);
para.Add("save_path:" + save_path);
para.Add("speed:1");
para.Add("actor:NA");
return para.ToArray().ToDelimiteredList(' ');
}
private string PackSoVITSTtsTaskParameters(string save_path, string bookId, string chapterId)
{ {
//速度快,音质差 //速度快,音质差
//task:TtsTask book_id:B000008 chapter_id:3 speed:1 voice:Sherpa2 actor:韩立 actor_voice:Sherpa1 save_path:D:\\Net8\\FileServer\\Backup\\DmsFile\\voice //task:TtsTask book_id:B000008 chapter_id:3 speed:1 voice:Sherpa2 actor:韩立 actor_voice:Sherpa1 save_path:D:\\Net8\\FileServer\\Backup\\DmsFile\\voice

View File

@ -3,7 +3,7 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<_PublishTargetUrl>C:\inetpub\wwwroot\webapi</_PublishTargetUrl> <_PublishTargetUrl>C:\inetpub\wwwroot\webapi</_PublishTargetUrl>
<History>True|2026-06-23T02:11:00.8522806Z||;</History> <History>True|2026-06-24T00:26:55.0324041Z||;True|2026-06-24T08:21:40.3334931+08:00||;True|2026-06-24T08:20:33.0781131+08:00||;True|2026-06-24T08:09:48.1948679+08:00||;True|2026-06-23T10:11:00.8522806+08:00||;</History>
<LastFailureDetails /> <LastFailureDetails />
</PropertyGroup> </PropertyGroup>
</Project> </Project>