This repository has been archived by the owner on Mar 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
音声合成周りのインターフェース・モック作成
- Loading branch information
Showing
12 changed files
with
120 additions
and
11 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
KoeBook.Core/Contracts/Services/ISoundGenerationSelectorService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Contracts.Services; | ||
|
||
public interface ISoundGenerationSelectorService | ||
{ | ||
/// <summary> | ||
/// サウンドモデル・スタイルの一覧 | ||
/// </summary> | ||
public IReadOnlyList<SoundModel> Models { get; } | ||
|
||
public ValueTask InitializeAsync(CancellationToken cancellationToken); | ||
} |
15 changes: 15 additions & 0 deletions
15
KoeBook.Core/Contracts/Services/ISoundGenerationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Contracts.Services; | ||
|
||
public interface ISoundGenerationService | ||
{ | ||
/// <summary> | ||
/// 1文の音声を生成します | ||
/// </summary> | ||
/// <param name="scriptLine"></param> | ||
/// <param name="bookOptions"></param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
ValueTask<byte[]> GenerateLineSoundAsync(ScriptLine scriptLine, BookOptions bookOptions, CancellationToken cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace KoeBook.Core.Models; | ||
|
||
public record SoundModel( | ||
string name, | ||
IReadOnlyList<string> styles); |
22 changes: 22 additions & 0 deletions
22
KoeBook.Core/Services/Mocks/SoundGenerationSelectorServiceMock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Services.Mocks; | ||
|
||
internal class SoundGenerationSelectorServiceMock : ISoundGenerationSelectorService | ||
{ | ||
public IReadOnlyList<SoundModel> Models { get; private set; } = []; | ||
|
||
public async ValueTask InitializeAsync(CancellationToken cancellationToken) | ||
{ | ||
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); | ||
Models = [ | ||
new SoundModel("青年1", ["neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
new SoundModel("青年2", ["neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
new SoundModel("女性1", ["neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
new SoundModel("女性2", ["neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
new SoundModel("ナレーション (男性)", ["narration"]), | ||
new SoundModel("ナレーション (女性)", ["narration"]), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Services.Mocks; | ||
|
||
public class SoundGenerationServiceMock : ISoundGenerationService | ||
{ | ||
public async ValueTask<byte[]> GenerateLineSoundAsync(ScriptLine scriptLine, BookOptions bookOptions, CancellationToken cancellationToken) | ||
{ | ||
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); | ||
// 適当なバイト列を返す | ||
var random = new Random(); | ||
var buffer = new byte[44100 * 2]; | ||
random.NextBytes(buffer); | ||
return buffer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace KoeBook.Models; | ||
|
||
internal class MockOptions | ||
{ | ||
public bool? ISoundGenerationSelectorService { get; set; } | ||
|
||
public bool? ISoundGenerationService { get; set; } | ||
} |
19 changes: 19 additions & 0 deletions
19
KoeBook/Services/CoreMocks/SoundGenerationSelectorServiceMock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using KoeBook.Core.Contracts.Services; | ||
using KoeBook.Core.Models; | ||
|
||
namespace KoeBook.Core.Services.Mocks; | ||
|
||
internal class SoundGenerationSelectorServiceMock : ISoundGenerationSelectorService | ||
{ | ||
public IReadOnlyList<SoundModel> Models { get; private set; } = []; | ||
|
||
public async ValueTask InitializeAsync(CancellationToken cancellationToken) | ||
{ | ||
await Task.Delay(1000, cancellationToken).ConfigureAwait(false); | ||
Models = [ | ||
new SoundModel("青年1", ["neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
new SoundModel("青年2", ["neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
new SoundModel("王", ["narration", "neutral", "laughing", "happy", "sad", "cry", "surprised", "angry"]), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{ | ||
{ | ||
"LocalSettingsOptions": { | ||
"ApplicationDataFolder": "KoeBook/ApplicationData", | ||
"LocalSettingsFile": "LocalSettings.json" | ||
"ApplicationDataFolder": "KoeBook/ApplicationData", | ||
"LocalSettingsFile": "LocalSettings.json" | ||
}, | ||
"MockOptions": { | ||
"ISoundGenerationSelectorService": false, | ||
"ISoundGenerationService": false | ||
} | ||
} |