Adopt PanPhon realization channel
This commit is contained in:
parent
13c29fea12
commit
21c1046f9d
11 changed files with 89 additions and 27 deletions
|
|
@ -89,8 +89,19 @@ public sealed class EspeakNgGradientDescentTests
|
|||
private static TrainingFixture Fixture(string id, string text, PhoneticFeatures features, IReadOnlyList<float> textEmbedding)
|
||||
{
|
||||
var prosody = new[] { 0.75f, text.Length / 4f, features.Manner == PhoneticManner.Fricative ? 0.95f : 0.35f, features.Manner == PhoneticManner.Nasal ? 0.80f : 0.25f };
|
||||
var phoneticRealization = new[]
|
||||
{
|
||||
features.Manner == PhoneticManner.Vowel ? 1f : 0f,
|
||||
features.Manner == PhoneticManner.Stop ? 1f : 0f,
|
||||
features.Manner == PhoneticManner.Fricative ? 1f : 0f,
|
||||
features.Manner == PhoneticManner.Nasal ? 1f : 0f,
|
||||
features.Place == PhoneticPlace.Bilabial ? 1f : 0f,
|
||||
features.Place == PhoneticPlace.Alveolar ? 1f : 0f,
|
||||
features.Place == PhoneticPlace.Velar ? 1f : 0f,
|
||||
features.Phonation == Phonation.Voiced ? 1f : 0f
|
||||
};
|
||||
var characterState = new[] { 0.65f, 0.35f, 0.55f, features.Place == PhoneticPlace.Bilabial ? 0.72f : 0.28f };
|
||||
var input = new UtteranceEmbeddingInput(textEmbedding, prosody, characterState);
|
||||
var input = new UtteranceEmbeddingInput(textEmbedding, phoneticRealization, prosody, characterState);
|
||||
var phoneticEvent = new PhoneticEvent(id, text, features, DurationSeconds: 0.20, Prosody: new PhoneticProsody(Stress: 0.75f, Intensity: 0.8f));
|
||||
return new TrainingFixture(id, text, "en", phoneticEvent, input);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public sealed class SpeechBackpropagationPipelineTests
|
|||
public void SpeechPipelineBackpropagatesSynthDriverLossIntoUtteranceEncoder()
|
||||
{
|
||||
var utteranceEncoder = UtteranceEmbeddingNeuralEncoder.Create(
|
||||
inputSize: 10,
|
||||
inputSize: 13,
|
||||
embeddingSize: 16,
|
||||
hiddenLayerSizes: [48, 32, 24],
|
||||
seed: 211);
|
||||
|
|
@ -37,7 +37,7 @@ public sealed class SpeechBackpropagationPipelineTests
|
|||
public void SpeechPipelineAcceptsExternalRenderedLossGradient()
|
||||
{
|
||||
var utteranceEncoder = UtteranceEmbeddingNeuralEncoder.Create(
|
||||
inputSize: 10,
|
||||
inputSize: 13,
|
||||
embeddingSize: 8,
|
||||
hiddenLayerSizes: [24, 16],
|
||||
seed: 301);
|
||||
|
|
@ -50,7 +50,7 @@ public sealed class SpeechBackpropagationPipelineTests
|
|||
var example = Example(
|
||||
"a",
|
||||
new PhoneticFeatures(PhoneticManner.Vowel, Height: VowelHeight.Open, Backness: VowelBackness.Front),
|
||||
new UtteranceEmbeddingInput([0.9f, 0.1f, 0.2f, 0.7f], [0.8f, 0.3f, 0.2f], [0.6f, 0.2f, 0.4f]),
|
||||
new UtteranceEmbeddingInput([0.9f, 0.1f, 0.2f, 0.7f], [0.9f, 0.2f, 0.1f], [0.8f, 0.3f, 0.2f], [0.6f, 0.2f, 0.4f]),
|
||||
SmallTarget([0.9f, 0.7f, 0.3f, 0.1f]));
|
||||
var before = pipeline.Predict(example).ToVector(pipeline.SynthDriver.MelBandCount);
|
||||
var gradient = new float[pipeline.SynthDriver.OutputSize];
|
||||
|
|
@ -77,17 +77,17 @@ public sealed class SpeechBackpropagationPipelineTests
|
|||
Example(
|
||||
"a",
|
||||
new PhoneticFeatures(PhoneticManner.Vowel, Height: VowelHeight.Open, Backness: VowelBackness.Front),
|
||||
new UtteranceEmbeddingInput([0.92f, 0.20f, 0.35f, 0.70f], [0.88f, 0.32f, 0.20f], [0.65f, 0.20f, 0.44f]),
|
||||
new UtteranceEmbeddingInput([0.92f, 0.20f, 0.35f, 0.70f], [0.90f, 0.18f, 0.10f], [0.88f, 0.32f, 0.20f], [0.65f, 0.20f, 0.44f]),
|
||||
Target([0.82f, 0.74f, 0.66f, 0.58f, 0.50f, 0.42f, 0.34f, 0.28f, 0.22f, 0.18f, 0.16f, 0.14f])),
|
||||
Example(
|
||||
"sa",
|
||||
new PhoneticFeatures(PhoneticManner.Fricative, PhoneticPlace.Alveolar, Phonation.Voiceless),
|
||||
new UtteranceEmbeddingInput([0.35f, 0.42f, 0.90f, 0.44f], [0.70f, 0.92f, 0.75f], [0.28f, 0.60f, 0.82f]),
|
||||
new UtteranceEmbeddingInput([0.35f, 0.42f, 0.90f, 0.44f], [0.22f, 0.86f, 0.76f], [0.70f, 0.92f, 0.75f], [0.28f, 0.60f, 0.82f]),
|
||||
Target([0.12f, 0.16f, 0.22f, 0.34f, 0.48f, 0.62f, 0.76f, 0.88f, 0.94f, 0.90f, 0.82f, 0.72f])),
|
||||
Example(
|
||||
"ma",
|
||||
new PhoneticFeatures(PhoneticManner.Nasal, PhoneticPlace.Bilabial, Phonation.Voiced, Nasalized: true),
|
||||
new UtteranceEmbeddingInput([0.72f, 0.52f, 0.24f, 0.64f], [0.62f, 0.40f, 0.32f], [0.74f, 0.80f, 0.36f]),
|
||||
new UtteranceEmbeddingInput([0.72f, 0.52f, 0.24f, 0.64f], [0.70f, 0.60f, 0.82f], [0.62f, 0.40f, 0.32f], [0.74f, 0.80f, 0.36f]),
|
||||
Target([0.68f, 0.72f, 0.70f, 0.62f, 0.54f, 0.46f, 0.40f, 0.36f, 0.32f, 0.30f, 0.28f, 0.26f]))
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public sealed class SpeechDistributedTrainingTests
|
|||
private static SpeechBackpropagationPipeline Pipeline()
|
||||
{
|
||||
var utteranceEncoder = UtteranceEmbeddingNeuralEncoder.Create(
|
||||
inputSize: 10,
|
||||
inputSize: 13,
|
||||
embeddingSize: 8,
|
||||
hiddenLayerSizes: [24, 16],
|
||||
seed: 701);
|
||||
|
|
@ -106,17 +106,17 @@ public sealed class SpeechDistributedTrainingTests
|
|||
Example(
|
||||
"a",
|
||||
new PhoneticFeatures(PhoneticManner.Vowel, Height: VowelHeight.Open, Backness: VowelBackness.Front),
|
||||
new UtteranceEmbeddingInput([0.92f, 0.20f, 0.35f, 0.70f], [0.88f, 0.32f, 0.20f], [0.65f, 0.20f, 0.44f]),
|
||||
new UtteranceEmbeddingInput([0.92f, 0.20f, 0.35f, 0.70f], [0.90f, 0.18f, 0.10f], [0.88f, 0.32f, 0.20f], [0.65f, 0.20f, 0.44f]),
|
||||
Target([0.82f, 0.74f, 0.66f, 0.58f, 0.50f, 0.42f])),
|
||||
Example(
|
||||
"sa",
|
||||
new PhoneticFeatures(PhoneticManner.Fricative, PhoneticPlace.Alveolar, Phonation.Voiceless),
|
||||
new UtteranceEmbeddingInput([0.35f, 0.42f, 0.90f, 0.44f], [0.70f, 0.92f, 0.75f], [0.28f, 0.60f, 0.82f]),
|
||||
new UtteranceEmbeddingInput([0.35f, 0.42f, 0.90f, 0.44f], [0.22f, 0.86f, 0.76f], [0.70f, 0.92f, 0.75f], [0.28f, 0.60f, 0.82f]),
|
||||
Target([0.12f, 0.16f, 0.22f, 0.34f, 0.48f, 0.62f])),
|
||||
Example(
|
||||
"ma",
|
||||
new PhoneticFeatures(PhoneticManner.Nasal, PhoneticPlace.Bilabial, Phonation.Voiced, Nasalized: true),
|
||||
new UtteranceEmbeddingInput([0.72f, 0.52f, 0.24f, 0.64f], [0.62f, 0.40f, 0.32f], [0.74f, 0.80f, 0.36f]),
|
||||
new UtteranceEmbeddingInput([0.72f, 0.52f, 0.24f, 0.64f], [0.70f, 0.60f, 0.82f], [0.62f, 0.40f, 0.32f], [0.74f, 0.80f, 0.36f]),
|
||||
Target([0.68f, 0.72f, 0.70f, 0.62f, 0.54f, 0.46f]))
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -5,16 +5,33 @@ namespace AquaSynth.Dsl.Tests;
|
|||
public sealed class UtteranceEmbeddingLearningTests
|
||||
{
|
||||
[Fact]
|
||||
public void UtteranceEmbeddingInputPacksTextProsodyAndCharacterState()
|
||||
public void UtteranceEmbeddingInputPacksTextPhoneticsProsodyAndCharacterState()
|
||||
{
|
||||
var input = new UtteranceEmbeddingInput(
|
||||
SpeechTextEmbedding: [0.1f, 0.2f, 0.3f],
|
||||
PhoneticRealizationVector: [0.9f, 0.6f],
|
||||
ProsodyAndEmphasisHints: [0.7f, 0.8f],
|
||||
CharacterStateVector: [0.4f, 0.5f, 0.6f]);
|
||||
|
||||
var features = input.ToFeatureVector();
|
||||
|
||||
Assert.Equal([0.1f, 0.2f, 0.3f, 0.7f, 0.8f, 0.4f, 0.5f, 0.6f], features.Values);
|
||||
Assert.Equal([0.1f, 0.2f, 0.3f, 0.9f, 0.6f, 0.7f, 0.8f, 0.4f, 0.5f, 0.6f], features.Values);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WeksaV01ContractRequiresSeparatePanphonRealizationChannel()
|
||||
{
|
||||
var input = new UtteranceEmbeddingInput(
|
||||
SpeechTextEmbedding: Zeros(WeksaUtteranceEmbeddingHandoff.SpeechTextEmbeddingSize),
|
||||
PhoneticRealizationVector: Zeros(WeksaUtteranceEmbeddingHandoff.PhoneticRealizationVectorSize),
|
||||
ProsodyAndEmphasisHints: Zeros(WeksaUtteranceEmbeddingHandoff.ProsodyAndEmphasisHintSize),
|
||||
CharacterStateVector: Zeros(WeksaUtteranceEmbeddingHandoff.CharacterStateVectorSize));
|
||||
|
||||
WeksaUtteranceEmbeddingHandoff.Validate(input);
|
||||
|
||||
Assert.Equal("weksa.utterance_embedding_handoff.v0.1", WeksaUtteranceEmbeddingHandoff.SchemaVersion);
|
||||
Assert.Equal("weksa.panphon_realization.v0.1", WeksaUtteranceEmbeddingHandoff.PhoneticRealizationModelId);
|
||||
Assert.Equal(1376, input.ToFeatureVector().Values.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -103,4 +120,6 @@ public sealed class UtteranceEmbeddingLearningTests
|
|||
|
||||
private static float Lerp(float left, float right, float amount) =>
|
||||
left + (right - left) * amount;
|
||||
|
||||
private static float[] Zeros(int count) => new float[count];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue