Skip to content

Commit

Permalink
Merge pull request #16 from OUCC/feat/#15-change-dependency
Browse files Browse the repository at this point in the history
#15 プロジェクトの依存関係を変更
  • Loading branch information
miyaji255 authored Mar 13, 2024
2 parents d0303d8 + a56c8bb commit e3a124c
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 25 deletions.
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 @@ -56,7 +57,9 @@ public async ValueTask<BookScripts> AnalyzeAsync(BookProperties bookProperties,
// ルビを置換
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

0 comments on commit e3a124c

Please sign in to comment.