Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#15 プロジェクトの依存関係を変更 #16

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using KoeBook.Epub.Models;

namespace KoeBook.Core.Contracts.Services;
namespace KoeBook.Epub.Contracts.Services;

public interface IEpubDocumentStoreService
{
Expand Down
6 changes: 5 additions & 1 deletion Epub/KoeBook.Epub/KoeBook.Epub.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -11,5 +11,9 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\KoeBook.Core\KoeBook.Core.csproj" />
</ItemGroup>

</Project>
7 changes: 5 additions & 2 deletions Epub/KoeBook.Epub/Models/Paragraph.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using KoeBook.Epub;
using KoeBook.Epub.Services;

namespace KoeBook.Core.Services;
namespace KoeBook.Epub.Services;

public partial class AnalyzerService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -44,7 +45,7 @@
{
var line = paragraph.Text;
// rubyタグがあればルビのdictionaryに登録
var rubyDict = ExtractRuby(line);

Check warning on line 48 in Epub/KoeBook.Epub/Services/AnalyzerService.cs

View workflow job for this annotation

GitHub Actions / test

Possible null reference argument for parameter 'text' in 'Dictionary<string, string> AnalyzerService.ExtractRuby(string text)'.

Check warning on line 48 in Epub/KoeBook.Epub/Services/AnalyzerService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'text' in 'Dictionary<string, string> AnalyzerService.ExtractRuby(string text)'.

Check warning on line 48 in Epub/KoeBook.Epub/Services/AnalyzerService.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'text' in 'Dictionary<string, string> AnalyzerService.ExtractRuby(string text)'.

foreach (var ruby in rubyDict)
{
Expand All @@ -56,7 +57,9 @@
// ルビを置換
line = ReplaceBaseTextWithRuby(line, rubyDict);

scriptLines.Add(new ScriptLine(paragraph, line, "", ""));
var scriptLine = new ScriptLine(line, "", "");
paragraph.ScriptLine = scriptLine;
scriptLines.Add(scriptLine);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -21,7 +22,7 @@ public async ValueTask<string> 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))
Expand Down
7 changes: 2 additions & 5 deletions KoeBook.Core/KoeBook.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>KoeBook.Core</RootNamespace>
Expand All @@ -11,10 +11,7 @@
<ItemGroup>
<PackageReference Include="Betalgo.OpenAI" Version="7.4.6" />
<PackageReference Include="FastEnum" Version="1.8.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Epub\KoeBook.Epub\KoeBook.Epub.csproj" />
</ItemGroup>
</Project>
File renamed without changes.
13 changes: 8 additions & 5 deletions KoeBook.Core/Models/ScriptLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ namespace KoeBook.Core.Models;
/// <summary>
/// 読み上げ1行分
/// </summary>
public class ScriptLine(Paragraph paragraph, string text, string character, string style)
//public class ScriptLine(Paragraph paragraph, string text, string character, string style)
//{
// /// <summary>
// /// 読み上げ位置との関連付け
// /// </summary>
// public Paragraph Paragraph { get; } = paragraph;
public class ScriptLine(string text, string character, string style)
{
/// <summary>
/// 読み上げ位置との関連付け
/// </summary>
public Paragraph Paragraph { get; } = paragraph;
public Audio? Audio { get; set; }

/// <summary>
/// 読み上げテキスト
Expand Down
6 changes: 3 additions & 3 deletions KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public async ValueTask<BookScripts> 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"),
],
};
}
Expand Down
Loading