コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
852c33d066
|
||
|
|
3127791ae2
|
||
|
|
f1d68e637c
|
||
|
|
c8c16aafd5
|
||
|
|
b52a81ea61
|
検索条件に一致するファイルはありません
@@ -296,6 +296,48 @@ public sealed class KanaRomanizationTests
|
||||
Assert.Equal("アヴヶ", KanaRomanization.ToKatakana("あゔゖ"));
|
||||
Assert.Equal("ー", KanaRomanization.ToHiragana("ー"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("ka", "か")]
|
||||
[InlineData("KA", "か")]
|
||||
[InlineData("shi", "し")]
|
||||
[InlineData("n", "ん")]
|
||||
[InlineData("kya", "きゃ")]
|
||||
public void RomajiIsReadAsTheKanaMora(string lyric, string expected)
|
||||
=> Assert.Equal(expected, KanaRomanization.ToMora(lyric));
|
||||
|
||||
[Theory]
|
||||
[InlineData("ji", "じ")]
|
||||
[InlineData("zu", "ず")]
|
||||
[InlineData("o", "お")]
|
||||
[InlineData("ja", "じゃ")]
|
||||
public void AmbiguousRomajiPicksTheCommonKana(string lyric, string expected)
|
||||
=> Assert.Equal(expected, KanaRomanization.ToMora(lyric));
|
||||
|
||||
[Theory]
|
||||
[InlineData("a あ", "あ")]
|
||||
[InlineData("- あ", "あ")]
|
||||
[InlineData("a カ", "か")]
|
||||
[InlineData("a ka", "か")]
|
||||
public void TheContinuousPrefixIsDropped(string lyric, string expected)
|
||||
=> Assert.Equal(expected, KanaRomanization.ToMora(lyric));
|
||||
|
||||
[Fact]
|
||||
public void RomajiAndContinuousLyricsExposeTheirVowelAndConsonant()
|
||||
{
|
||||
Assert.Equal("a", KanaRomanization.GetVowel("ka"));
|
||||
Assert.Equal("k", KanaRomanization.GetConsonant("ka"));
|
||||
Assert.Equal("a", KanaRomanization.GetVowel("a か"));
|
||||
Assert.Equal("k", KanaRomanization.GetConsonant("a か"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("漢", "漢")]
|
||||
[InlineData("", "")]
|
||||
[InlineData("a k", "k")]
|
||||
[InlineData("あ ", "")]
|
||||
public void TextWithoutAKnownMoraIsLeftAsItIs(string lyric, string expected)
|
||||
=> Assert.Equal(expected, KanaRomanization.ToMora(lyric));
|
||||
}
|
||||
|
||||
public sealed class TempoNotationTests
|
||||
|
||||
@@ -202,16 +202,41 @@ public sealed class NoteEditorMeasuredLayoutTests
|
||||
Assert.Equal(0.0, worst, 6);
|
||||
}
|
||||
|
||||
static StackPanel Toolbar(Border host)
|
||||
=> Descend(host)
|
||||
.OfType<StackPanel>()
|
||||
.First(x => x.Orientation == Orientation.Horizontal
|
||||
&& x.Children.OfType<ComboBox>().Any());
|
||||
|
||||
[Fact]
|
||||
public void TheToolbarComboBoxTextIsCentredInItsRow()
|
||||
{
|
||||
var gaps = RunSta(() =>
|
||||
{
|
||||
var (_, _, host) = Build();
|
||||
return Toolbar(host).Children
|
||||
.OfType<ComboBox>()
|
||||
.Select(combo =>
|
||||
{
|
||||
var text = Descend(combo).OfType<TextBlock>().First();
|
||||
var above = TopOf(text, combo);
|
||||
return (Above: above, Below: combo.ActualHeight - above - text.ActualHeight);
|
||||
})
|
||||
.ToArray();
|
||||
});
|
||||
|
||||
Assert.NotEmpty(gaps);
|
||||
Assert.All(gaps, x => Assert.True(x.Above > 0.0, $"above={x.Above}"));
|
||||
Assert.All(gaps, x => Assert.Equal(x.Above, x.Below, 6));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TheToolbarControlsAllFillTheToolbarRow()
|
||||
{
|
||||
var boxes = RunSta(() =>
|
||||
{
|
||||
var (_, _, host) = Build();
|
||||
var toolbar = Descend(host)
|
||||
.OfType<StackPanel>()
|
||||
.First(x => x.Orientation == Orientation.Horizontal
|
||||
&& x.Children.OfType<ComboBox>().Any());
|
||||
var toolbar = Toolbar(host);
|
||||
|
||||
return toolbar.Children
|
||||
.OfType<Control>()
|
||||
|
||||
@@ -123,6 +123,33 @@ public sealed class AliasResolverTests
|
||||
[Fact]
|
||||
public void UnknownMoraeStillOfferTheLiteralAlias()
|
||||
=> Assert.Contains("漢", AliasResolver.EnumerateCandidates("漢", "-"));
|
||||
|
||||
[Fact]
|
||||
public void RomajiLyricsAlsoOfferTheKanaForms()
|
||||
{
|
||||
var candidates = AliasResolver.EnumerateCandidates("ka", "a").ToArray();
|
||||
Assert.Equal("a ka", candidates[0]);
|
||||
Assert.Contains("a か", candidates);
|
||||
Assert.Contains("か", candidates);
|
||||
Assert.Contains("カ", candidates);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContinuousLyricsAlsoOfferTheSingleForms()
|
||||
{
|
||||
var candidates = AliasResolver.EnumerateCandidates("a あ", "-").ToArray();
|
||||
Assert.Contains("a あ", candidates);
|
||||
Assert.Contains("- あ", candidates);
|
||||
Assert.Contains("あ", candidates);
|
||||
Assert.Contains("a", candidates);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddedCandidatesStayDistinct()
|
||||
{
|
||||
var candidates = AliasResolver.EnumerateCandidates("a カ", "i").ToArray();
|
||||
Assert.Equal(candidates.Length, candidates.Distinct(StringComparer.Ordinal).Count());
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class PhonemizerTests : IDisposable
|
||||
@@ -206,6 +233,47 @@ public sealed class PhonemizerTests : IDisposable
|
||||
Assert.DoesNotContain("a -", units.Select(x => x.Alias));
|
||||
}
|
||||
|
||||
static IReadOnlyList<UTAUNote> Lyrics(params string[] lyrics)
|
||||
=> [.. lyrics.Select(x => new UTAUNote { Lyric = x, LengthTicks = TimeBase.TicksPerQuarterNote, Tone = 60 })];
|
||||
|
||||
[Fact]
|
||||
public void SingleKanaBankAcceptsRomajiLyrics()
|
||||
{
|
||||
var bank = TestVoiceBank.CreateSingleKanaBank(directory);
|
||||
var units = Phonemize(bank, Lyrics("a", "ka", "sa"));
|
||||
|
||||
Assert.Equal(["あ", "か", "さ"], units.Select(x => x.Alias));
|
||||
Assert.All(units, x => Assert.False(x.IsUnresolved));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SingleKanaBankAcceptsContinuousLyrics()
|
||||
{
|
||||
var bank = TestVoiceBank.CreateSingleKanaBank(directory);
|
||||
var units = Phonemize(bank, Lyrics("- あ", "a か"));
|
||||
|
||||
Assert.Equal(["あ", "か"], units.Select(x => x.Alias));
|
||||
Assert.All(units, x => Assert.False(x.IsUnresolved));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContinuousBankAcceptsRomajiLyrics()
|
||||
{
|
||||
var bank = TestVoiceBank.CreateVcvBank(directory);
|
||||
var units = Phonemize(bank, Lyrics("a", "ka"));
|
||||
|
||||
Assert.Equal(["- あ", "a か"], units.Select(x => x.Alias));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ContinuousLyricsFollowTheActualPreviousVowel()
|
||||
{
|
||||
var bank = TestVoiceBank.CreateVcvBank(directory);
|
||||
var units = Phonemize(bank, Lyrics("i あ", "e か"));
|
||||
|
||||
Assert.Equal(["- あ", "a か"], units.Select(x => x.Alias));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnresolvedLyricsAreReportedWithoutAnEntry()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Threading;
|
||||
using UTAU.Notes;
|
||||
using UTAU.ViewModels;
|
||||
using UTAU.Views;
|
||||
using YukkuriMovieMaker.Controls;
|
||||
|
||||
namespace UTAU.Tests;
|
||||
|
||||
public sealed class RenderMessageDisplayTests
|
||||
{
|
||||
const double PopupWidth = 980.0;
|
||||
const double PopupHeight = 480.0;
|
||||
const string Warning = "見つからない歌詞";
|
||||
|
||||
[Fact]
|
||||
public void TheWarningReachesTheToolbarFromTheSynthesisThread()
|
||||
{
|
||||
Exception? error = null;
|
||||
string? shown = null;
|
||||
|
||||
var thread = new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var editor = new NoteEditor();
|
||||
var button = (PopupButton)editor.Content;
|
||||
var root = (Grid)button.PopupContent!;
|
||||
button.PopupContent = null;
|
||||
|
||||
var pronounce = new UTAUVoicePronounce();
|
||||
pronounce.Notes.Add(new UTAUNote { Lyric = "あ" });
|
||||
using var viewModel = new NoteEditorViewModel(pronounce);
|
||||
root.DataContext = viewModel;
|
||||
|
||||
var host = new Border { Width = PopupWidth, Height = PopupHeight, Child = root };
|
||||
host.Measure(new Size(PopupWidth, PopupHeight));
|
||||
host.Arrange(new Rect(0.0, 0.0, PopupWidth, PopupHeight));
|
||||
host.UpdateLayout();
|
||||
|
||||
Task.Run(() => pronounce.RenderMessage = Warning).GetAwaiter().GetResult();
|
||||
viewModel.InvalidateMessages();
|
||||
Dispatcher.CurrentDispatcher.Invoke(() => { }, DispatcherPriority.Background);
|
||||
|
||||
shown = ((StackPanel)root.Children[0]).Children.OfType<TextBlock>().Last().Text;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
error = exception;
|
||||
}
|
||||
});
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
thread.Join();
|
||||
|
||||
Assert.Null(error);
|
||||
Assert.Equal(Warning, shown);
|
||||
}
|
||||
}
|
||||
@@ -281,6 +281,16 @@ public sealed class UtauRendererTests : IDisposable
|
||||
Assert.True(Peak(result.Samples) > 0.01);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnknownLyricsAreSkippedWithoutStoppingTheRest()
|
||||
{
|
||||
var bank = TestVoiceBank.CreateSingleKanaBank(directory);
|
||||
var result = Render(bank, "<!C4:1/4>あ<!C4:1/4>ぱ<!C4:1/4>あ");
|
||||
|
||||
Assert.Equal(2, result.Timings.Count);
|
||||
Assert.True(Peak(result.Samples) > 0.01);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UnitsWithoutAnyRenderableEntryProduceAnEmptyResult()
|
||||
{
|
||||
|
||||
@@ -31,6 +31,8 @@ internal static class AliasResolver
|
||||
{
|
||||
var hiragana = KanaRomanization.ToHiragana(lyric);
|
||||
var katakana = KanaRomanization.ToKatakana(lyric);
|
||||
var mora = KanaRomanization.ToMora(lyric);
|
||||
var moraKatakana = KanaRomanization.ToKatakana(mora);
|
||||
KanaRomanization.TryGetRomaji(lyric, out var romaji);
|
||||
|
||||
if (previousVowel.Length > 0)
|
||||
@@ -38,6 +40,8 @@ internal static class AliasResolver
|
||||
yield return previousVowel + " " + lyric;
|
||||
yield return previousVowel + " " + hiragana;
|
||||
yield return previousVowel + " " + katakana;
|
||||
yield return previousVowel + " " + mora;
|
||||
yield return previousVowel + " " + moraKatakana;
|
||||
if (romaji is not null)
|
||||
yield return previousVowel + " " + romaji;
|
||||
}
|
||||
@@ -45,6 +49,8 @@ internal static class AliasResolver
|
||||
yield return lyric;
|
||||
yield return hiragana;
|
||||
yield return katakana;
|
||||
yield return mora;
|
||||
yield return moraKatakana;
|
||||
if (romaji is not null)
|
||||
yield return romaji;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ internal static class KanaRomanization
|
||||
{
|
||||
public const string StartVowel = "-";
|
||||
public const string SilenceConsonant = "-";
|
||||
public const char AliasSeparator = ' ';
|
||||
|
||||
static readonly Dictionary<string, string> Table = new(StringComparer.Ordinal)
|
||||
{
|
||||
@@ -49,8 +50,32 @@ internal static class KanaRomanization
|
||||
|
||||
static readonly char[] Vowels = ['a', 'i', 'u', 'e', 'o'];
|
||||
|
||||
static readonly Dictionary<string, string> Kana = BuildKana();
|
||||
|
||||
public static bool TryGetRomaji(string mora, out string romaji)
|
||||
=> Table.TryGetValue(ToHiragana(mora), out romaji!);
|
||||
=> Table.TryGetValue(ToMora(mora), out romaji!);
|
||||
|
||||
public static string ToMora(string lyric)
|
||||
{
|
||||
var separator = lyric.LastIndexOf(AliasSeparator);
|
||||
var hiragana = ToHiragana(separator >= 0 ? lyric[(separator + 1)..] : lyric);
|
||||
if (Table.ContainsKey(hiragana))
|
||||
return hiragana;
|
||||
|
||||
return Kana.TryGetValue(hiragana, out var mapped) ? mapped : hiragana;
|
||||
}
|
||||
|
||||
static Dictionary<string, string> BuildKana()
|
||||
{
|
||||
var kana = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var pair in Table)
|
||||
{
|
||||
if (kana.TryGetValue(pair.Value, out var existing) && string.CompareOrdinal(existing, pair.Key) <= 0)
|
||||
continue;
|
||||
kana[pair.Value] = pair.Key;
|
||||
}
|
||||
return kana;
|
||||
}
|
||||
|
||||
public static string? GetVowel(string mora)
|
||||
{
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>1.0.0</Version>
|
||||
<Version>1.1.0</Version>
|
||||
<Platforms>AnyCPU;x64;x64</Platforms>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
|
||||
@@ -13,6 +13,7 @@ internal sealed class UTAUVoicePronounce : UndoRedoable, IVoicePronounce
|
||||
{
|
||||
string sourceText = string.Empty;
|
||||
string importMessage = string.Empty;
|
||||
string renderMessage = string.Empty;
|
||||
double tempo = TimeBase.DefaultTempo;
|
||||
double speed = 1.0;
|
||||
LipSyncFrame[]? lipSyncFrames;
|
||||
@@ -65,6 +66,13 @@ internal sealed class UTAUVoicePronounce : UndoRedoable, IVoicePronounce
|
||||
set => Set(ref importMessage, value ?? string.Empty);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public string RenderMessage
|
||||
{
|
||||
get => renderMessage;
|
||||
set => Set(ref renderMessage, value ?? string.Empty);
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public LipSyncFrame[]? LipSyncFrames
|
||||
{
|
||||
|
||||
@@ -79,7 +79,8 @@ internal sealed class UTAUVoiceSpeaker(VoiceBank bank) : IVoiceSpeaker
|
||||
void Render(string source, UTAUVoicePronounce pronounce, UTAUVoiceParameter parameter, TempoMap tempoMap, string filePath)
|
||||
{
|
||||
var units = Phonemizer.Phonemize(bank, tempoMap, parameter.Color, PhonemizeOptions.Default);
|
||||
ThrowIfUnresolved(units);
|
||||
var unresolved = DescribeUnresolved(units);
|
||||
pronounce.RenderMessage = unresolved;
|
||||
|
||||
var settings = new RenderSettings(
|
||||
UTAUSettings.Default.F0Estimator,
|
||||
@@ -93,7 +94,7 @@ internal sealed class UTAUVoiceSpeaker(VoiceBank bank) : IVoiceSpeaker
|
||||
var renderer = new UtauRenderer(settings, BuildCurves(pronounce, tempoMap), AnalysisCache.Shared);
|
||||
var result = renderer.Render(units, arena);
|
||||
if (result.Samples.Length == 0)
|
||||
throw new InvalidOperationException(Texts.NoRenderableNoteMessage);
|
||||
throw new InvalidOperationException(unresolved.Length > 0 ? unresolved : Texts.NoRenderableNoteMessage);
|
||||
|
||||
WaveIo.Write(filePath, result.Samples, result.SampleRate);
|
||||
pronounce.SourceText = source;
|
||||
@@ -109,7 +110,7 @@ internal sealed class UTAUVoiceSpeaker(VoiceBank bank) : IVoiceSpeaker
|
||||
return new RenderCurves(resampled.Formant, resampled.Breathiness, resampled.IntervalMilliseconds);
|
||||
}
|
||||
|
||||
static void ThrowIfUnresolved(IReadOnlyList<PhonemeUnit> units)
|
||||
static string DescribeUnresolved(IReadOnlyList<PhonemeUnit> units)
|
||||
{
|
||||
var unresolved = units
|
||||
.Where(x => x.IsUnresolved)
|
||||
@@ -117,12 +118,12 @@ internal sealed class UTAUVoiceSpeaker(VoiceBank bank) : IVoiceSpeaker
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.ToArray();
|
||||
if (unresolved.Length == 0)
|
||||
return;
|
||||
return string.Empty;
|
||||
|
||||
var listed = string.Join(", ", unresolved.Take(MaximumReportedUnresolvedLyrics));
|
||||
if (unresolved.Length > MaximumReportedUnresolvedLyrics)
|
||||
listed += " ...";
|
||||
throw new InvalidOperationException(string.Format(Texts.AliasNotFoundMessage, listed));
|
||||
return string.Format(Texts.AliasNotFoundMessage, listed);
|
||||
}
|
||||
|
||||
static LipSyncFrame[] BuildLipSyncFrames(TempoMap tempoMap, double offsetMilliseconds)
|
||||
|
||||
@@ -117,6 +117,8 @@ internal sealed class NoteEditorViewModel : Bindable, IDisposable
|
||||
|
||||
public string ImportMessage => pronounce.ImportMessage;
|
||||
|
||||
public string RenderMessage => pronounce.RenderMessage;
|
||||
|
||||
public ICommand AddPitchPointCommand { get; }
|
||||
|
||||
public ICommand RemovePitchPointCommand { get; }
|
||||
@@ -405,6 +407,12 @@ internal sealed class NoteEditorViewModel : Bindable, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
public void InvalidateMessages()
|
||||
{
|
||||
OnPropertyChanged(nameof(ImportMessage));
|
||||
OnPropertyChanged(nameof(RenderMessage));
|
||||
}
|
||||
|
||||
public void InvalidateTones()
|
||||
{
|
||||
UpdateToneRange();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
xmlns:vm="clr-namespace:UTAU.ViewModels"
|
||||
xmlns:c="clr-namespace:YukkuriMovieMaker.Controls;assembly=YukkuriMovieMaker.Controls"
|
||||
xmlns:icons="clr-namespace:YukkuriMovieMaker.Resources.Icons;assembly=YukkuriMovieMaker.Plugin"
|
||||
xmlns:theme="clr-namespace:YukkuriMovieMaker.Theme;assembly=YukkuriMovieMaker.Plugin"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="440" d:DesignWidth="960"
|
||||
d:DataContext="{d:DesignInstance Type={x:Type vm:NoteEditorViewModel}}">
|
||||
@@ -53,12 +54,12 @@
|
||||
<Button Width="26" Height="26" Command="{Binding SelectAllCommand}" ToolTip="{x:Static root:Texts.SelectAllNotes}"
|
||||
Content="{DynamicResource {x:Static icons:IconKeys.SelectAll}}"/>
|
||||
<TextBlock Text="{x:Static root:Texts.SnapLabel}" VerticalAlignment="Center" Margin="6,0,3,0"/>
|
||||
<ComboBox Width="88" Height="26"
|
||||
<ComboBox Width="88" Height="26" VerticalContentAlignment="Center"
|
||||
ItemsSource="{Binding SnapDivisions}"
|
||||
SelectedItem="{Binding SnapDivision}"
|
||||
DisplayMemberPath="Name"/>
|
||||
<TextBlock Text="{x:Static root:Texts.ExpressionLabel}" VerticalAlignment="Center" Margin="12,0,3,0"/>
|
||||
<ComboBox Width="110" Height="26"
|
||||
<ComboBox Width="110" Height="26" VerticalContentAlignment="Center"
|
||||
ItemsSource="{Binding Expressions}"
|
||||
SelectedItem="{Binding SelectedExpression}"
|
||||
DisplayMemberPath="Name"/>
|
||||
@@ -68,6 +69,9 @@
|
||||
<TextBlock Text="{Binding GuideText}" VerticalAlignment="Center" Margin="12,0,0,0" Opacity="0.75"/>
|
||||
<TextBlock Text="{Binding ImportMessage}" VerticalAlignment="Center" Margin="12,0,0,0" Opacity="0.75"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
<TextBlock Text="{Binding RenderMessage}" VerticalAlignment="Center" Margin="12,0,0,0"
|
||||
Foreground="{DynamicResource {x:Static theme:YMM4Colors.WarningBannerForegroundBrushKey}}"
|
||||
TextTrimming="CharacterEllipsis"/>
|
||||
</StackPanel>
|
||||
|
||||
<ScrollViewer x:Name="VerticalScroller" Grid.Row="1" Grid.Column="0"
|
||||
|
||||
@@ -80,7 +80,11 @@ public partial class NoteEditor : UserControl, IPropertyEditorControl
|
||||
|
||||
void Scroller_SizeChanged(object sender, SizeChangedEventArgs e) => UpdateFit();
|
||||
|
||||
void PopupButton_BeginEdit(object sender, EventArgs e) => BeginEdit?.Invoke(this, e);
|
||||
void PopupButton_BeginEdit(object sender, EventArgs e)
|
||||
{
|
||||
ViewModel?.InvalidateMessages();
|
||||
BeginEdit?.Invoke(this, e);
|
||||
}
|
||||
|
||||
void PopupButton_EndEdit(object sender, EventArgs e) => EndEdit?.Invoke(this, e);
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする