From a56c8bbcf2140c041ae3529f883f432c644204a6 Mon Sep 17 00:00:00 2001 From: miyaji255 <84168445+miyaji255@users.noreply.github.com> Date: Mon, 11 Mar 2024 22:05:55 +0900 Subject: [PATCH] =?UTF-8?q?#15=20=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=81=AE=E4=BE=9D=E5=AD=98=E9=96=A2=E4=BF=82?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Contracts/Services/IEpubDocumentStoreService.cs | 2 +- Epub/KoeBook.Epub/KoeBook.Epub.csproj | 6 +++++- Epub/KoeBook.Epub/Models/Paragraph.cs | 7 +++++-- .../Services/AnalyzerService _CoverFileBytes.cs | 2 +- .../KoeBook.Epub}/Services/AnalyzerService.cs | 7 +++++-- .../Services/EpubDocumentStoreService.cs | 4 ++-- .../KoeBook.Epub}/Services/EpubGenerateService.cs | 7 ++++--- KoeBook.Core/KoeBook.Core.csproj | 7 ++----- {Epub/KoeBook.Epub => KoeBook.Core}/Models/Audio.cs | 0 KoeBook.Core/Models/ScriptLine.cs | 13 ++++++++----- KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs | 6 +++--- 11 files changed, 36 insertions(+), 25 deletions(-) rename {KoeBook.Core => Epub/KoeBook.Epub}/Contracts/Services/IEpubDocumentStoreService.cs (84%) rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/AnalyzerService _CoverFileBytes.cs (99%) rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/AnalyzerService.cs (94%) rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/EpubDocumentStoreService.cs (93%) rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/EpubGenerateService.cs (85%) rename {Epub/KoeBook.Epub => KoeBook.Core}/Models/Audio.cs (100%) diff --git a/KoeBook.Core/Contracts/Services/IEpubDocumentStoreService.cs b/Epub/KoeBook.Epub/Contracts/Services/IEpubDocumentStoreService.cs similarity index 84% rename from KoeBook.Core/Contracts/Services/IEpubDocumentStoreService.cs rename to Epub/KoeBook.Epub/Contracts/Services/IEpubDocumentStoreService.cs index 8ba00b9..187e9a4 100644 --- a/KoeBook.Core/Contracts/Services/IEpubDocumentStoreService.cs +++ b/Epub/KoeBook.Epub/Contracts/Services/IEpubDocumentStoreService.cs @@ -1,6 +1,6 @@ using KoeBook.Epub.Models; -namespace KoeBook.Core.Contracts.Services; +namespace KoeBook.Epub.Contracts.Services; public interface IEpubDocumentStoreService { diff --git a/Epub/KoeBook.Epub/KoeBook.Epub.csproj b/Epub/KoeBook.Epub/KoeBook.Epub.csproj index 8f3071f..2241bce 100644 --- a/Epub/KoeBook.Epub/KoeBook.Epub.csproj +++ b/Epub/KoeBook.Epub/KoeBook.Epub.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -11,5 +11,9 @@ + + + + diff --git a/Epub/KoeBook.Epub/Models/Paragraph.cs b/Epub/KoeBook.Epub/Models/Paragraph.cs index ea1956c..9faffe9 100644 --- a/Epub/KoeBook.Epub/Models/Paragraph.cs +++ b/Epub/KoeBook.Epub/Models/Paragraph.cs @@ -1,7 +1,10 @@ -namespace KoeBook.Epub.Models; +using KoeBook.Core.Models; + +namespace KoeBook.Epub.Models; public sealed class Paragraph : Element { - public Audio? Audio { get; set; } + public ScriptLine? ScriptLine { get; set; } + public Audio? Audio => ScriptLine?.Audio; public string? Text { get; set; } } diff --git a/KoeBook.Core/Services/AnalyzerService _CoverFileBytes.cs b/Epub/KoeBook.Epub/Services/AnalyzerService _CoverFileBytes.cs similarity index 99% rename from KoeBook.Core/Services/AnalyzerService _CoverFileBytes.cs rename to Epub/KoeBook.Epub/Services/AnalyzerService _CoverFileBytes.cs index 97c30e8..6e0673c 100644 --- a/KoeBook.Core/Services/AnalyzerService _CoverFileBytes.cs +++ b/Epub/KoeBook.Epub/Services/AnalyzerService _CoverFileBytes.cs @@ -5,7 +5,7 @@ using KoeBook.Epub; using KoeBook.Epub.Services; -namespace KoeBook.Core.Services; +namespace KoeBook.Epub.Services; public partial class AnalyzerService { diff --git a/KoeBook.Core/Services/AnalyzerService.cs b/Epub/KoeBook.Epub/Services/AnalyzerService.cs similarity index 94% rename from KoeBook.Core/Services/AnalyzerService.cs rename to Epub/KoeBook.Epub/Services/AnalyzerService.cs index 59b72a6..b8fa5cb 100644 --- a/KoeBook.Core/Services/AnalyzerService.cs +++ b/Epub/KoeBook.Epub/Services/AnalyzerService.cs @@ -1,11 +1,12 @@ using System.Text; using System.Text.RegularExpressions; +using KoeBook.Core; using KoeBook.Core.Contracts.Services; using KoeBook.Core.Models; using KoeBook.Epub.Contracts.Services; using KoeBook.Epub.Models; -namespace KoeBook.Core.Services; +namespace KoeBook.Epub.Services; public partial class AnalyzerService(IScraperSelectorService scrapingService, IEpubDocumentStoreService epubDocumentStoreService, ILlmAnalyzerService llmAnalyzerService) : IAnalyzerService { @@ -56,7 +57,9 @@ public async ValueTask AnalyzeAsync(BookProperties bookProperties, // ルビを置換 line = ReplaceBaseTextWithRuby(line, rubyDict); - scriptLines.Add(new ScriptLine(paragraph, line, "", "")); + var scriptLine = new ScriptLine(line, "", ""); + paragraph.ScriptLine = scriptLine; + scriptLines.Add(scriptLine); } } } diff --git a/KoeBook.Core/Services/EpubDocumentStoreService.cs b/Epub/KoeBook.Epub/Services/EpubDocumentStoreService.cs similarity index 93% rename from KoeBook.Core/Services/EpubDocumentStoreService.cs rename to Epub/KoeBook.Epub/Services/EpubDocumentStoreService.cs index 4c51415..0ef2725 100644 --- a/KoeBook.Core/Services/EpubDocumentStoreService.cs +++ b/Epub/KoeBook.Epub/Services/EpubDocumentStoreService.cs @@ -1,8 +1,8 @@ using System.Threading.Tasks; -using KoeBook.Core.Contracts.Services; +using KoeBook.Epub.Contracts.Services; using KoeBook.Epub.Models; -namespace KoeBook.Core.Services; +namespace KoeBook.Epub.Services; public class EpubDocumentStoreService : IEpubDocumentStoreService { diff --git a/KoeBook.Core/Services/EpubGenerateService.cs b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs similarity index 85% rename from KoeBook.Core/Services/EpubGenerateService.cs rename to Epub/KoeBook.Epub/Services/EpubGenerateService.cs index 2810e8d..058795d 100644 --- a/KoeBook.Core/Services/EpubGenerateService.cs +++ b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs @@ -1,10 +1,11 @@ -using KoeBook.Core.Contracts.Services; +using KoeBook.Core; +using KoeBook.Core.Contracts.Services; using KoeBook.Core.Models; using KoeBook.Epub; using KoeBook.Epub.Contracts.Services; using KoeBook.Epub.Models; -namespace KoeBook.Core.Services; +namespace KoeBook.Epub.Services; public class EpubGenerateService(ISoundGenerationService soundGenerationService, IEpubDocumentStoreService epubDocumentStoreService, IEpubCreateService epubCreateService) : IEpubGenerateService { @@ -21,7 +22,7 @@ public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string foreach (var scriptLine in bookScripts.ScriptLines) { - scriptLine.Paragraph.Audio = new Audio(await _soundGenerationService.GenerateLineSoundAsync(scriptLine, bookScripts.Options, cancellationToken).ConfigureAwait(false)); + scriptLine.Audio = new Audio(await _soundGenerationService.GenerateLineSoundAsync(scriptLine, bookScripts.Options, cancellationToken).ConfigureAwait(false)); } if (await _createService.TryCreateEpubAsync(document, tempDirectory, cancellationToken).ConfigureAwait(false)) diff --git a/KoeBook.Core/KoeBook.Core.csproj b/KoeBook.Core/KoeBook.Core.csproj index 92b37e0..3963f59 100644 --- a/KoeBook.Core/KoeBook.Core.csproj +++ b/KoeBook.Core/KoeBook.Core.csproj @@ -1,4 +1,4 @@ - + net8.0 KoeBook.Core @@ -11,10 +11,7 @@ + - - - - diff --git a/Epub/KoeBook.Epub/Models/Audio.cs b/KoeBook.Core/Models/Audio.cs similarity index 100% rename from Epub/KoeBook.Epub/Models/Audio.cs rename to KoeBook.Core/Models/Audio.cs diff --git a/KoeBook.Core/Models/ScriptLine.cs b/KoeBook.Core/Models/ScriptLine.cs index 7f7cbec..3fcb5e4 100644 --- a/KoeBook.Core/Models/ScriptLine.cs +++ b/KoeBook.Core/Models/ScriptLine.cs @@ -5,12 +5,15 @@ namespace KoeBook.Core.Models; /// /// 読み上げ1行分 /// -public class ScriptLine(Paragraph paragraph, string text, string character, string style) +//public class ScriptLine(Paragraph paragraph, string text, string character, string style) +//{ +// /// +// /// 読み上げ位置との関連付け +// /// +// public Paragraph Paragraph { get; } = paragraph; +public class ScriptLine(string text, string character, string style) { - /// - /// 読み上げ位置との関連付け - /// - public Paragraph Paragraph { get; } = paragraph; + public Audio? Audio { get; set; } /// /// 読み上げテキスト diff --git a/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs b/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs index 6e6432f..04468bf 100644 --- a/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs +++ b/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs @@ -40,9 +40,9 @@ public async ValueTask AnalyzeAsync(BookProperties bookProperties, return new(bookProperties, new(characterMapping)) { ScriptLines = [ - new(new Paragraph { Text = "a" }, "読み上げテキスト1", "Hoge", "Angry"), - new(new Paragraph { Text = "b" }, "読み上げテキスト2", "Fuga", "Sad"), - new(new Paragraph { Text = "c" }, "読み上げテキスト3", "Narration", "Narration"), + new("読み上げテキスト1", "Hoge", "Angry"), + new("読み上げテキスト2", "Fuga", "Sad"), + new("読み上げテキスト3", "Narration", "Narration"), ], }; }