diff --git a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs index 51423a7..3b10b73 100644 --- a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs +++ b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs @@ -27,7 +27,8 @@ public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string using var reader = new WaveFileReader(ms); var tmpMp3Path = Path.Combine(tempDirectory, $"{document.Title}{i}.mp3"); MediaFoundationEncoder.EncodeToMp3(reader, tmpMp3Path); - scriptLine.Audio = new Audio(reader.TotalTime, tmpMp3Path); + using var mp3Stream = new Mp3FileReader(tmpMp3Path); + scriptLine.Audio = new Audio(mp3Stream.TotalTime, tmpMp3Path); } if (await _createService.TryCreateEpubAsync(document, tempDirectory, cancellationToken).ConfigureAwait(false)) diff --git a/KoeBook.Core/Services/ClaudeAnalyzerService.cs b/KoeBook.Core/Services/ClaudeAnalyzerService.cs index 3d1dd8a..ba072e2 100644 --- a/KoeBook.Core/Services/ClaudeAnalyzerService.cs +++ b/KoeBook.Core/Services/ClaudeAnalyzerService.cs @@ -174,10 +174,15 @@ private static (Character[], Dictionary) ExtractCharacterList(st var voiceIdLine = zippedLine.First.AsSpan(); voiceIdLine = voiceIdLine[(voiceIdLine.IndexOf(' ') + 2)..];//cまで無視 voiceIdLine = voiceIdLine[..voiceIdLine.IndexOf(' ')];// 二人以上話す時には先頭のものを使う + if (voiceIdLine[^1] == '.')// idに"."がつくことがあるので削除する + { + voiceIdLine = voiceIdLine[..^1]; + } if (characterId2Name.TryGetValue(voiceIdLine.ToString(), out var characterName)) { zippedLine.Second.Character = characterName; } + else { throw new EbookException(ExceptionType.ClaudeTalkerAndStyleSettingFailed); } return 0; }).Count(); if (voiceIdLinesCount != scriptLines.Length)