diff --git a/docs/ipa-vocal-tract-roadmap.md b/docs/ipa-vocal-tract-roadmap.md index b383ec4..982af5e 100644 --- a/docs/ipa-vocal-tract-roadmap.md +++ b/docs/ipa-vocal-tract-roadmap.md @@ -587,6 +587,48 @@ spent, what latency budget it was meant to respect, and how confident the mapping was. A tiny audible witness that sounds right but arrives from a clockless swamp is already teaching the model to lie with a lovely voice. +### Frozen IPA Gesture Rounds + +`IpaGestureExperiment.WriteRound` is the first batch surface for IPA hypothesis +work. It writes a frozen round bundle under a caller-provided artifact root: + +- `manifest.yaml`: target IPA descriptors, variant knobs, candidate script + paths, primitive timeline paths, and the authority boundary for the round. +- `candidates/*.aqua`: deterministic primitive vocal scripts using + `phoneme_gesture` plus the public `ControlSurface`/`ControlSpline` path. +- `timelines/*.csv`: `ProbeTimelineReport` output for each candidate before + audio parity. +- `metrics.csv`: first-layer `gesture` metrics only: + `surface_coverage`, `motion_direction`, `contour_timing`, + `primitive_timeline`, and `gesture_score`. +- `evidence.jsonl`: one short machine-readable receipt per candidate for later + science passes. + +`IpaGestureExperiment.AnalyzeRound` adds the deterministic science packet: + +- `analysis/metric-summary.csv`: per-target metric mean, min, max, spread, and + best/worst candidate IDs. +- `analysis/candidate-clusters.csv`: `strong`, `workable`, and `weak` + candidate bands by `gesture_score`. +- `analysis/science-brief.md`: a compact handoff for a human or sub-agent to + inspect score surfaces, clusters, and next hypothesis pressure. + +This round writer owns frozen candidate evidence. It does not own clean vocal +identity, full spectrogram parity, optimizer checkpoints, or distributed worker +orchestration. Those stages may consume the bundle later, but they must add +their own scores instead of rewriting gesture evidence after the fact. + +The intended scale-out loop is brutally simple: + +1. Generate a round of descriptor/variant candidates and primitive timelines. +2. Hand the frozen bundle to a science worker for loss-landscape summaries, + clustering, outlier detection, and next-hypothesis recommendations. +3. While that worker runs, generate another round with new DSL or patch + variations. +4. Merge only conclusions that improve the layered evidence ledger: + `gesture_score` first, then `clean_vocal_score`, then + `full_parity_score`. + ## CultMesh Render/Scoring Work CultMesh is the transport, admission, and worker-orchestration layer for speech diff --git a/docs/utterance-parity-research.md b/docs/utterance-parity-research.md index 4907365..c136b0f 100644 --- a/docs/utterance-parity-research.md +++ b/docs/utterance-parity-research.md @@ -136,6 +136,17 @@ Only the third score is allowed to reward recording-condition helpers. The first score is where IPA labels and anatomical descriptors prove that the right organs were asked to move. +The first scalable IPA training loop starts with frozen gesture rounds, not a +free-running optimizer. `IpaGestureExperiment.WriteRound` produces candidate +scripts, primitive timelines, gesture metrics, a manifest, and evidence JSONL +for a whole batch. `IpaGestureExperiment.AnalyzeRound` then writes metric +summaries, score-band clusters, and a science brief. A science worker can +inspect that immutable bundle for clusters, outliers, loss surfaces, and +promising descriptor/variant changes while the foreground process writes the +next batch. This keeps hypothesis generation, primitive evidence, and +statistical analysis separate enough to argue with each other. Good. Machines +get less stupid when their witnesses are allowed to disagree. + Do not start serious gradient descent from toy embedding packets. The first training contract coordinated with Weksa is `weksa.utterance_embedding_handoff.v0.1`: 1024 speech-text floats from diff --git a/src/AquaSynth.Core/IpaGestureExperiment.cs b/src/AquaSynth.Core/IpaGestureExperiment.cs new file mode 100644 index 0000000..fed8db1 --- /dev/null +++ b/src/AquaSynth.Core/IpaGestureExperiment.cs @@ -0,0 +1,728 @@ +using System.Globalization; +using System.Text; + +namespace AquaSynth.Dsl; + +public sealed record IpaGestureExperimentTarget( + string Id, + string Ipa, + string Descriptor, + float DurationSeconds = 0.18f, + string Notes = ""); + +public sealed record IpaGestureExperimentVariant( + string Id, + float IntensityScale = 1, + float DurationScale = 1, + IReadOnlyList? Tags = null, + string Notes = "") +{ + public IReadOnlyList Tags { get; init; } = Tags ?? Array.Empty(); +} + +public sealed record IpaGestureExperimentCandidate( + string Id, + string TargetId, + string VariantId, + string ScriptPath, + string TimelinePath, + IReadOnlyList Tags) +{ + public IReadOnlyList Tags { get; init; } = Tags ?? Array.Empty(); +} + +public sealed record IpaGestureExperimentMetric( + string CandidateId, + string TargetId, + string Layer, + string Metric, + float Value); + +public sealed record IpaGestureExperimentResult( + string RoundId, + string RoundDirectory, + string ManifestPath, + string MetricsPath, + string EvidencePath, + IReadOnlyList Candidates, + IReadOnlyList Metrics) +{ + public IReadOnlyList Candidates { get; init; } = Candidates ?? Array.Empty(); + public IReadOnlyList Metrics { get; init; } = Metrics ?? Array.Empty(); +} + +public sealed record IpaGestureMetricSummary( + string TargetId, + string Metric, + float Mean, + float Minimum, + float Maximum, + float Spread, + string BestCandidateId, + string WorstCandidateId); + +public sealed record IpaGestureCandidateCluster( + string TargetId, + string Cluster, + IReadOnlyList CandidateIds, + float MeanGestureScore) +{ + public IReadOnlyList CandidateIds { get; init; } = CandidateIds ?? Array.Empty(); +} + +public sealed record IpaGestureExperimentAnalysisResult( + string AnalysisDirectory, + string ScienceBriefPath, + string MetricSummaryPath, + string CandidateClustersPath, + IReadOnlyList MetricSummaries, + IReadOnlyList CandidateClusters) +{ + public IReadOnlyList MetricSummaries { get; init; } = MetricSummaries ?? Array.Empty(); + public IReadOnlyList CandidateClusters { get; init; } = CandidateClusters ?? Array.Empty(); +} + +public static class IpaGestureExperiment +{ + private const string NetworkName = "voice"; + + public static IpaGestureExperimentResult WriteRound( + string rootDirectory, + string roundId, + IEnumerable targets, + IEnumerable variants, + int timelineBlocks = 12) + { + ArgumentException.ThrowIfNullOrWhiteSpace(rootDirectory); + ArgumentException.ThrowIfNullOrWhiteSpace(roundId); + + var targetList = targets.ToArray(); + var variantList = variants.ToArray(); + if (targetList.Length == 0) + { + throw new ArgumentException("At least one IPA target is required.", nameof(targets)); + } + + if (variantList.Length == 0) + { + throw new ArgumentException("At least one experiment variant is required.", nameof(variants)); + } + + var roundDirectory = Path.Combine(rootDirectory, SafeFileName(roundId)); + var candidateDirectory = Path.Combine(roundDirectory, "candidates"); + var timelineDirectory = Path.Combine(roundDirectory, "timelines"); + Directory.CreateDirectory(candidateDirectory); + Directory.CreateDirectory(timelineDirectory); + + var candidates = new List(); + var metrics = new List(); + var evidence = new List(); + + foreach (var target in targetList) + { + foreach (var variant in variantList) + { + var candidateId = SafeFileName($"{target.Id}-{variant.Id}"); + var script = BuildCandidateScript(target, variant); + var scriptPath = Path.Combine(candidateDirectory, $"{candidateId}.aqua"); + File.WriteAllText(scriptPath, script, Encoding.UTF8); + + var patch = PatchScript.Parse(script); + var timeline = ProbeTimelineReport.Build(patch, NetworkName, Math.Max(1, timelineBlocks)); + var timelinePath = Path.Combine(timelineDirectory, $"{candidateId}.csv"); + File.WriteAllText(timelinePath, ProbeTimelineReport.ToCsv(timeline), Encoding.UTF8); + + var tags = variant.Tags.Concat(DescriptorTokens(target.Descriptor).Select(token => $"descriptor:{token}")).ToArray(); + var candidate = new IpaGestureExperimentCandidate(candidateId, target.Id, variant.Id, scriptPath, timelinePath, tags); + candidates.Add(candidate); + + var scored = ScoreGesture(candidate, target, patch, timeline); + metrics.AddRange(scored); + evidence.Add(EvidenceLine(roundId, candidate, target, variant, scored)); + } + } + + var manifestPath = Path.Combine(roundDirectory, "manifest.yaml"); + File.WriteAllText(manifestPath, Manifest(roundId, targetList, variantList, candidates), Encoding.UTF8); + + var metricsPath = Path.Combine(roundDirectory, "metrics.csv"); + File.WriteAllText(metricsPath, MetricsCsv(metrics), Encoding.UTF8); + + var evidencePath = Path.Combine(roundDirectory, "evidence.jsonl"); + File.WriteAllText(evidencePath, string.Join(Environment.NewLine, evidence) + Environment.NewLine, Encoding.UTF8); + + return new IpaGestureExperimentResult( + roundId, + roundDirectory, + manifestPath, + metricsPath, + evidencePath, + candidates, + metrics); + } + + public static IpaGestureExperimentAnalysisResult AnalyzeRound(IpaGestureExperimentResult result) + { + ArgumentNullException.ThrowIfNull(result); + var analysisDirectory = Path.Combine(result.RoundDirectory, "analysis"); + Directory.CreateDirectory(analysisDirectory); + + var summaries = SummarizeMetrics(result.Metrics); + var clusters = ClusterCandidates(result.Metrics); + + var summaryPath = Path.Combine(analysisDirectory, "metric-summary.csv"); + File.WriteAllText(summaryPath, MetricSummaryCsv(summaries), Encoding.UTF8); + + var clusterPath = Path.Combine(analysisDirectory, "candidate-clusters.csv"); + File.WriteAllText(clusterPath, CandidateClusterCsv(clusters), Encoding.UTF8); + + var briefPath = Path.Combine(analysisDirectory, "science-brief.md"); + File.WriteAllText(briefPath, ScienceBrief(result, summaries, clusters), Encoding.UTF8); + + return new IpaGestureExperimentAnalysisResult( + analysisDirectory, + briefPath, + summaryPath, + clusterPath, + summaries, + clusters); + } + + public static string BuildCandidateScript(IpaGestureExperimentTarget target, IpaGestureExperimentVariant variant) + { + ArgumentException.ThrowIfNullOrWhiteSpace(target.Id); + ArgumentException.ThrowIfNullOrWhiteSpace(target.Ipa); + ArgumentException.ThrowIfNullOrWhiteSpace(variant.Id); + + var duration = Math.Clamp(target.DurationSeconds * variant.DurationScale, 0.03f, 1.5f); + var intensity = Math.Clamp(variant.IntensityScale, 0.05f, 2f); + var sustain = Math.Clamp(duration + 0.12f, 0.15f, 2f); + var descriptor = target.Descriptor.Replace(' ', '_'); + var frequency = DescriptorTokens(target.Descriptor).Contains("vowel") ? 150 : 135; + + return $$""" + patch gain=.22 + morphology name=oral length_cm=17 diameters=.55,.75,1.05,1.45,1.25,.8 tongue_index=3 tongue_diameter=1.4 constriction_index=4 constriction_diameter=1 lip_opening=1.2 + morphology name=nasal length_cm=12 diameters=.04,.28,.52,.72 + waveguide_path name=oral_path morphology=oral strategy=thiran order=1 max_delay=4096 loss=.998 + waveguide_path name=nasal_path morphology=nasal strategy=thiran order=1 max_delay=4096 loss=.997 + source_port name=folds path=oral_path kind=glottal position=0 pressure=.66 tension=.54 opening=.42 noise=.04 impedance=.32 flow_scale=.02 + branch_port name=velopharynx from=oral_path from_position=.45 to=nasal_path opening=.01 coupling=1 + constriction_contact name=contact path=oral_path position=.92 opening=.5 resistance=.45 stored_pressure=.12 + radiation_load name=mouth path=oral_path kind=lip position=1 aperture=.8 reflection=-.82 impedance=.28 + probe_timeline name=flow network=voice blocks=12 block_size=64 + vocal_network name=voice paths=oral_path,nasal_path sources=folds contacts=contact branches=velopharynx radiation=mouth probe=flow + phoneme_gesture name={{SafeDslName(target.Id)}} ipa={{target.Ipa}} descriptor={{descriptor}} start=0 dur={{Format(duration)}} intensity={{Format(intensity)}} + vocal network=voice freq={{Format(frequency)}} gain=.2 sustain={{Format(sustain)}} + """; + } + + private static IReadOnlyList SummarizeMetrics(IReadOnlyList metrics) => + metrics + .Where(metric => metric.Layer.Equals("gesture", StringComparison.OrdinalIgnoreCase)) + .GroupBy(metric => (metric.TargetId, metric.Metric)) + .Select(group => + { + var ordered = group.OrderBy(metric => metric.Value).ToArray(); + var minimum = ordered[0]; + var maximum = ordered[^1]; + return new IpaGestureMetricSummary( + group.Key.TargetId, + group.Key.Metric, + group.Average(metric => metric.Value), + minimum.Value, + maximum.Value, + maximum.Value - minimum.Value, + maximum.CandidateId, + minimum.CandidateId); + }) + .OrderBy(summary => summary.TargetId, StringComparer.OrdinalIgnoreCase) + .ThenBy(summary => summary.Metric, StringComparer.OrdinalIgnoreCase) + .ToArray(); + + private static IReadOnlyList ClusterCandidates(IReadOnlyList metrics) => + metrics + .Where(metric => metric.Metric.Equals("gesture_score", StringComparison.OrdinalIgnoreCase)) + .GroupBy(metric => (metric.TargetId, ClusterName(metric.Value))) + .Select(group => new IpaGestureCandidateCluster( + group.Key.TargetId, + group.Key.Item2, + group.Select(metric => metric.CandidateId).Order(StringComparer.OrdinalIgnoreCase).ToArray(), + group.Average(metric => metric.Value))) + .OrderBy(cluster => cluster.TargetId, StringComparer.OrdinalIgnoreCase) + .ThenBy(cluster => ClusterRank(cluster.Cluster)) + .ToArray(); + + private static IReadOnlyList ScoreGesture( + IpaGestureExperimentCandidate candidate, + IpaGestureExperimentTarget target, + SynthPatch patch, + IReadOnlyList timeline) + { + var tokens = DescriptorTokens(target.Descriptor); + var expected = ExpectedSurfaces(tokens); + var touched = patch.ControlSplines + .Where(spline => spline.Enabled) + .Select(spline => spline.SurfacePath) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + + var coverage = expected.Length == 0 + ? 1 + : expected.Count(surface => touched.Contains(surface)) / (float)expected.Length; + var direction = DirectionScore(tokens, patch.ControlSplines); + var contour = ContourTimingScore(patch.ControlSplines); + var primitive = PrimitiveTimelineScore(tokens, timeline); + var score = 0.25f * coverage + 0.25f * direction + 0.20f * contour + 0.20f * primitive; + + return + [ + Metric("surface_coverage", coverage), + Metric("motion_direction", direction), + Metric("contour_timing", contour), + Metric("primitive_timeline", primitive), + Metric("gesture_score", score) + ]; + + IpaGestureExperimentMetric Metric(string name, float value) => + new(candidate.Id, target.Id, "gesture", name, Math.Clamp(value, 0, 1)); + } + + private static string[] ExpectedSurfaces(HashSet tokens) + { + var surfaces = new List + { + "/vocal/sources/0/pressure", + "/vocal/sources/0/tension", + "/vocal/sources/0/opening" + }; + + if (tokens.Contains("vowel")) + { + surfaces.AddRange( + [ + "/vocal/areas/0/area/tongue_index", + "/vocal/areas/0/area/tongue_diameter", + "/vocal/areas/0/area/lip_opening", + "/vocal/radiation/0/aperture" + ]); + } + else + { + surfaces.AddRange( + [ + "/vocal/areas/0/area/constriction_index", + "/vocal/areas/0/area/constriction_diameter", + "/vocal/contacts/0/opening" + ]); + } + + if (tokens.Contains("nasal")) + { + surfaces.Add("/vocal/branches/0/opening"); + } + + if (tokens.Contains("fricative")) + { + surfaces.Add("/vocal/sources/0/noise"); + surfaces.Add("/vocal/contacts/0/resistance"); + } + + if (tokens.Contains("plosive") || tokens.Contains("stop")) + { + surfaces.Add("/vocal/contacts/0/stored_pressure"); + } + + if (tokens.Contains("bilabial") || tokens.Contains("labial") || tokens.Contains("labiodental") || tokens.Contains("rounded")) + { + surfaces.Add("/vocal/areas/0/area/lip_opening"); + surfaces.Add("/vocal/radiation/0/aperture"); + } + + return surfaces.Distinct(StringComparer.OrdinalIgnoreCase).ToArray(); + } + + private static float DirectionScore(HashSet tokens, IReadOnlyList splines) + { + var checks = new List(); + if (tokens.Contains("nasal")) + { + checks.Add(Rises(splines, "/vocal/branches/0/opening")); + checks.Add(FallsOrReleases(splines, "/vocal/contacts/0/opening")); + } + + if (tokens.Contains("fricative")) + { + checks.Add(Rises(splines, "/vocal/sources/0/noise")); + checks.Add(HoldsNarrow(splines, "/vocal/areas/0/area/constriction_diameter")); + } + + if (tokens.Contains("plosive") || tokens.Contains("stop")) + { + checks.Add(Rises(splines, "/vocal/contacts/0/opening")); + checks.Add(Falls(splines, "/vocal/contacts/0/stored_pressure")); + } + + if (tokens.Contains("vowel")) + { + checks.Add(Exists(splines, "/vocal/areas/0/area/tongue_index")); + checks.Add(Exists(splines, "/vocal/areas/0/area/tongue_diameter")); + checks.Add(Exists(splines, "/vocal/radiation/0/aperture")); + } + + if (tokens.Contains("voiceless")) + { + checks.Add(Falls(splines, "/vocal/sources/0/tension")); + } + else + { + checks.Add(RisesOrHolds(splines, "/vocal/sources/0/tension")); + } + + return checks.Count == 0 ? 1 : checks.Average(); + } + + private static float ContourTimingScore(IReadOnlyList splines) + { + var enabled = splines.Where(spline => spline.Enabled).ToArray(); + if (enabled.Length == 0) + { + return 0; + } + + var scored = 0; + foreach (var spline in enabled) + { + var ordered = spline.Points.OrderBy(point => point.TimeSeconds).ToArray(); + if (ordered.Length < 2) + { + continue; + } + + var monotonic = ordered.Zip(ordered.Skip(1), (a, b) => b.TimeSeconds >= a.TimeSeconds).All(value => value); + var hasSpan = ordered[^1].TimeSeconds - ordered[0].TimeSeconds > 0.005f; + var valuesMove = ordered.Max(point => point.Value) - ordered.Min(point => point.Value) >= 0.0001f; + if (monotonic && hasSpan && valuesMove) + { + scored++; + } + } + + return scored / (float)enabled.Length; + } + + private static float PrimitiveTimelineScore(HashSet tokens, IReadOnlyList timeline) + { + if (timeline.Count == 0) + { + return 0; + } + + var checks = new List + { + Finite(timeline, "path:oral_path", "passivity_ratio"), + Finite(timeline, "source:folds", "flow"), + Finite(timeline, "radiation:mouth", "output") + }; + + if (tokens.Contains("nasal")) + { + checks.Add(Positive(timeline, "branch:velopharynx", "admittance")); + } + + if (tokens.Contains("fricative") || tokens.Contains("plosive") || tokens.Contains("stop") || tokens.Contains("nasal")) + { + checks.Add(Finite(timeline, "contact:contact", "opening")); + checks.Add(Finite(timeline, "contact:contact", "released_flow")); + } + + if (tokens.Contains("plosive") || tokens.Contains("stop")) + { + checks.Add(Positive(timeline, "contact:contact", "reservoir")); + } + + return checks.Average(); + } + + private static float Finite(IReadOnlyList timeline, string primitive, string signal) => + timeline.Any(sample => + sample.Primitive.Equals(primitive, StringComparison.OrdinalIgnoreCase) && + sample.Signal.Equals(signal, StringComparison.OrdinalIgnoreCase) && + float.IsFinite(sample.Value)) + ? 1 + : 0; + + private static float Positive(IReadOnlyList timeline, string primitive, string signal) => + timeline.Any(sample => + sample.Primitive.Equals(primitive, StringComparison.OrdinalIgnoreCase) && + sample.Signal.Equals(signal, StringComparison.OrdinalIgnoreCase) && + sample.Value > 0 && + float.IsFinite(sample.Value)) + ? 1 + : 0; + + private static float Exists(IReadOnlyList splines, string surface) => + splines.Any(spline => spline.Enabled && spline.SurfacePath.Equals(surface, StringComparison.OrdinalIgnoreCase)) ? 1 : 0; + + private static float Rises(IReadOnlyList splines, string surface) => + SignedMotion(splines, surface, (first, last) => last > first); + + private static float Falls(IReadOnlyList splines, string surface) => + SignedMotion(splines, surface, (first, last) => last < first); + + private static float RisesOrHolds(IReadOnlyList splines, string surface) => + SignedMotion(splines, surface, (first, last) => last >= first); + + private static float HoldsNarrow(IReadOnlyList splines, string surface) => + SignedMotion(splines, surface, (first, last) => Math.Max(first, last) <= 0.35f); + + private static float FallsOrReleases(IReadOnlyList splines, string surface) => + SignedMotion(splines, surface, (first, last) => last >= first || first <= 0.08f); + + private static float SignedMotion(IReadOnlyList splines, string surface, Func predicate) + { + var spline = splines.FirstOrDefault(item => item.Enabled && item.SurfacePath.Equals(surface, StringComparison.OrdinalIgnoreCase)); + if (spline is null || spline.Points.Count == 0) + { + return 0; + } + + var ordered = spline.Points.OrderBy(point => point.TimeSeconds).ToArray(); + return predicate(ordered[0].Value, ordered[^1].Value) ? 1 : 0; + } + + private static string Manifest( + string roundId, + IReadOnlyList targets, + IReadOnlyList variants, + IReadOnlyList candidates) + { + var builder = new StringBuilder(); + builder.AppendLine($"round_id: {Yaml(roundId)}"); + builder.AppendLine($"created_utc: {Yaml(DateTimeOffset.UtcNow.ToString("O", CultureInfo.InvariantCulture))}"); + builder.AppendLine("authority:"); + builder.AppendLine(" owns: frozen candidate scripts, primitive timelines, first-layer gesture metrics"); + builder.AppendLine(" does_not_own: clean vocal audio identity, full spectrogram parity, optimizer checkpoints, worker orchestration"); + builder.AppendLine("targets:"); + foreach (var target in targets) + { + builder.AppendLine($" - id: {Yaml(target.Id)}"); + builder.AppendLine($" ipa: {Yaml(target.Ipa)}"); + builder.AppendLine($" descriptor: {Yaml(target.Descriptor)}"); + builder.AppendLine($" duration_seconds: {Format(target.DurationSeconds)}"); + } + + builder.AppendLine("variants:"); + foreach (var variant in variants) + { + builder.AppendLine($" - id: {Yaml(variant.Id)}"); + builder.AppendLine($" intensity_scale: {Format(variant.IntensityScale)}"); + builder.AppendLine($" duration_scale: {Format(variant.DurationScale)}"); + builder.AppendLine($" tags: [{string.Join(", ", variant.Tags.Select(Yaml))}]"); + } + + builder.AppendLine("candidates:"); + foreach (var candidate in candidates) + { + builder.AppendLine($" - id: {Yaml(candidate.Id)}"); + builder.AppendLine($" target_id: {Yaml(candidate.TargetId)}"); + builder.AppendLine($" variant_id: {Yaml(candidate.VariantId)}"); + builder.AppendLine($" script: {Yaml(candidate.ScriptPath)}"); + builder.AppendLine($" primitive_timeline: {Yaml(candidate.TimelinePath)}"); + } + + return builder.ToString(); + } + + private static string MetricsCsv(IEnumerable metrics) + { + var builder = new StringBuilder(); + builder.AppendLine("candidate_id,target_id,layer,metric,value"); + foreach (var metric in metrics) + { + builder.Append(EscapeCsv(metric.CandidateId)); + builder.Append(','); + builder.Append(EscapeCsv(metric.TargetId)); + builder.Append(','); + builder.Append(EscapeCsv(metric.Layer)); + builder.Append(','); + builder.Append(EscapeCsv(metric.Metric)); + builder.Append(','); + builder.AppendLine(Format(metric.Value)); + } + + return builder.ToString(); + } + + private static string EvidenceLine( + string roundId, + IpaGestureExperimentCandidate candidate, + IpaGestureExperimentTarget target, + IpaGestureExperimentVariant variant, + IReadOnlyList metrics) + { + var score = metrics.First(metric => metric.Metric == "gesture_score").Value; + return "{" + + $"\"round_id\":\"{Json(roundId)}\"," + + $"\"candidate_id\":\"{Json(candidate.Id)}\"," + + $"\"target_id\":\"{Json(target.Id)}\"," + + $"\"ipa\":\"{Json(target.Ipa)}\"," + + $"\"descriptor\":\"{Json(target.Descriptor)}\"," + + $"\"variant_id\":\"{Json(variant.Id)}\"," + + $"\"gesture_score\":{Format(score)}," + + $"\"script\":\"{Json(candidate.ScriptPath)}\"," + + $"\"primitive_timeline\":\"{Json(candidate.TimelinePath)}\"" + + "}"; + } + + private static string MetricSummaryCsv(IEnumerable summaries) + { + var builder = new StringBuilder(); + builder.AppendLine("target_id,metric,mean,min,max,spread,best_candidate_id,worst_candidate_id"); + foreach (var summary in summaries) + { + builder.Append(EscapeCsv(summary.TargetId)); + builder.Append(','); + builder.Append(EscapeCsv(summary.Metric)); + builder.Append(','); + builder.Append(Format(summary.Mean)); + builder.Append(','); + builder.Append(Format(summary.Minimum)); + builder.Append(','); + builder.Append(Format(summary.Maximum)); + builder.Append(','); + builder.Append(Format(summary.Spread)); + builder.Append(','); + builder.Append(EscapeCsv(summary.BestCandidateId)); + builder.Append(','); + builder.AppendLine(EscapeCsv(summary.WorstCandidateId)); + } + + return builder.ToString(); + } + + private static string CandidateClusterCsv(IEnumerable clusters) + { + var builder = new StringBuilder(); + builder.AppendLine("target_id,cluster,mean_gesture_score,candidate_count,candidate_ids"); + foreach (var cluster in clusters) + { + builder.Append(EscapeCsv(cluster.TargetId)); + builder.Append(','); + builder.Append(EscapeCsv(cluster.Cluster)); + builder.Append(','); + builder.Append(Format(cluster.MeanGestureScore)); + builder.Append(','); + builder.Append(cluster.CandidateIds.Count); + builder.Append(','); + builder.AppendLine(EscapeCsv(string.Join('|', cluster.CandidateIds))); + } + + return builder.ToString(); + } + + private static string ScienceBrief( + IpaGestureExperimentResult result, + IReadOnlyList summaries, + IReadOnlyList clusters) + { + var builder = new StringBuilder(); + builder.AppendLine($"# IPA Gesture Experiment Science Brief: {result.RoundId}"); + builder.AppendLine(); + builder.AppendLine("Authority: this brief summarizes frozen gesture-layer evidence only. It does not accept or reject clean vocal audio, full spectrogram parity, optimizer checkpoints, or distributed worker behavior."); + builder.AppendLine(); + builder.AppendLine("## Score Surface"); + foreach (var summary in summaries.Where(summary => summary.Metric == "gesture_score")) + { + builder.Append("- "); + builder.Append(summary.TargetId); + builder.Append(": mean "); + builder.Append(Format(summary.Mean)); + builder.Append(", spread "); + builder.Append(Format(summary.Spread)); + builder.Append(", best "); + builder.Append(summary.BestCandidateId); + builder.Append(", worst "); + builder.AppendLine(summary.WorstCandidateId); + } + + builder.AppendLine(); + builder.AppendLine("## Candidate Clusters"); + foreach (var cluster in clusters) + { + builder.Append("- "); + builder.Append(cluster.TargetId); + builder.Append(' '); + builder.Append(cluster.Cluster); + builder.Append(": "); + builder.Append(cluster.CandidateIds.Count); + builder.Append(" candidates, mean "); + builder.Append(Format(cluster.MeanGestureScore)); + builder.Append(" ["); + builder.Append(string.Join(", ", cluster.CandidateIds)); + builder.AppendLine("]"); + } + + builder.AppendLine(); + builder.AppendLine("## Next Hypothesis Pressure"); + foreach (var weak in summaries + .Where(summary => summary.Metric != "gesture_score" && summary.Mean < 0.85f) + .OrderBy(summary => summary.Mean) + .ThenBy(summary => summary.TargetId, StringComparer.OrdinalIgnoreCase) + .Take(6)) + { + builder.Append("- "); + builder.Append(weak.TargetId); + builder.Append(' '); + builder.Append(weak.Metric); + builder.Append(" mean "); + builder.Append(Format(weak.Mean)); + builder.Append(": inspect "); + builder.Append(weak.WorstCandidateId); + builder.Append(" before tuning "); + builder.AppendLine(weak.BestCandidateId); + } + + return builder.ToString(); + } + + private static string ClusterName(float score) => + score >= 0.85f ? "strong" : score >= 0.60f ? "workable" : "weak"; + + private static int ClusterRank(string cluster) => cluster switch + { + "strong" => 0, + "workable" => 1, + _ => 2 + }; + + private static HashSet DescriptorTokens(string descriptor) => + descriptor + .ToLowerInvariant() + .Replace('-', '_') + .Split(['_', ',', '+', ' '], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) + .ToHashSet(StringComparer.OrdinalIgnoreCase); + + private static string SafeDslName(string value) => + new(value.Select(character => char.IsLetterOrDigit(character) ? character : '_').ToArray()); + + private static string SafeFileName(string value) + { + var invalid = Path.GetInvalidFileNameChars().ToHashSet(); + var safe = new string(value.Select(character => invalid.Contains(character) || char.IsWhiteSpace(character) ? '-' : character).ToArray()); + return safe.Length == 0 ? "candidate" : safe; + } + + private static string Format(float value) => + value.ToString("0.######", CultureInfo.InvariantCulture); + + private static string Yaml(string value) => + $"\"{value.Replace("\\", "\\\\", StringComparison.Ordinal).Replace("\"", "\\\"", StringComparison.Ordinal)}\""; + + private static string Json(string value) => + value.Replace("\\", "\\\\", StringComparison.Ordinal).Replace("\"", "\\\"", StringComparison.Ordinal); + + private static string EscapeCsv(string value) => + value.Contains(',') || value.Contains('"') || value.Contains('\n') || value.Contains('\r') + ? $"\"{value.Replace("\"", "\"\"", StringComparison.Ordinal)}\"" + : value; +} diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 4eb1c21..21c827d 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -235,3 +235,4 @@ {"date":"2026-05-29","area":"public-gesture-api","summary":"User-authored gestures now have a public runtime API. `ControlSurfaceCatalog.FromPatch(patch)` exposes normalized surface metadata; `ControlSplineTimeline` lets hosts edit future control points and produce per-time surface control dictionaries; `AquaSynthCompiledPatch.ControlSurfaces` carries the catalog through native Faust compilation; `AquaSynthCompiledPatch.ControlValuesAt(timeline,t)` filters semantic timeline values to the controls actually exported by optimized Faust DSP. This makes custom client gestures first-class without recompiling or relying on PT adapters. PatchScriptTests pass 91/91 and NativeFaustRuntimeTests pass 5/5.","evidence":"src/AquaSynth.Core/ControlSplineTimeline.cs; src/AquaSynth.Faust/NativeFaustRuntime.cs; tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs; tests/AquaSynth.Dsl.Tests/NativeFaustRuntimeTests.cs; docs/acoustic-graph-proprioception.md"} {"date":"2026-05-29","area":"ipa-phoneme-gesture-dsl","summary":"Added deterministic IPA/anatomy gesture sugar. `phoneme_gesture` records a symbol/descriptor/time/intensity and expands known IPA symbols or explicit place/manner/voicing descriptors into ordinary `ControlSpline`s over public source, area, branch, contact, and radiation surfaces. This gives local IPA-chart/audio datasets a seeded anatomical control path while preserving FM/AM/modulators/envelopes/filters as expressive patch tools around the anatomical stream. PatchScriptTests pass 92/92.","evidence":"src/AquaSynth.Core/Model.cs; src/AquaSynth.Core/PatchScript.cs; tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs; docs/acoustic-graph-proprioception.md"} {"date":"2026-05-29","area":"ipa-training-score-contract","summary":"Documented the speech training scoring contract. `gesture_score` measures descriptor-to-surface coverage, direction, spline contour/timing, primitive timeline consequences, and optional external articulation evidence. Training reports must keep `gesture_score`, `clean_vocal_score`, and `full_parity_score` separate. Full parity scripts may use FM/AM/modulators/envelopes/filters, auxiliary animated voices, and recording-condition helpers, but those helpers cannot be accepted as articulation evidence unless lower-layer gesture and clean-vocal scores also improve.","evidence":"docs/ipa-vocal-tract-roadmap.md; docs/utterance-parity-research.md; state/spine.yaml; state/scratch.md"} +{"date":"2026-05-29","area":"ipa-gesture-experiment-harness","summary":"Added `IpaGestureExperiment.WriteRound`, the first frozen batch surface for IPA hypothesis work. A round writes deterministic candidate `.aqua` scripts, primitive `ProbeTimelineReport` CSVs, `manifest.yaml`, gesture-layer `metrics.csv`, and per-candidate `evidence.jsonl`. `IpaGestureExperiment.AnalyzeRound` adds metric summaries, score-band candidate clusters, and a science brief for sub-agent analysis. The harness scores descriptor/spline/primitive evidence only and explicitly leaves clean vocal identity, full spectrogram parity, optimizer checkpoints, and worker orchestration downstream. PatchScriptTests pass 93/93.","evidence":"src/AquaSynth.Core/IpaGestureExperiment.cs; tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs; docs/ipa-vocal-tract-roadmap.md; docs/utterance-parity-research.md; state/map.yaml; state/spine.yaml; state/scratch.md"} diff --git a/state/map.yaml b/state/map.yaml index 42c8733..f7b31c0 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -58,6 +58,7 @@ modules: primitive_vocal_timeline: src/AquaSynth.Core/ProbeTimelineReport.cs primitive_control_spline_timeline: src/AquaSynth.Core/ControlSplineTimeline.cs primitive_vocal_reference_report: src/AquaSynth.Core/PrimitiveReferenceReport.cs + ipa_gesture_experiment: src/AquaSynth.Core/IpaGestureExperiment.cs acoustic_graph_missing_pieces_audit: docs/acoustic-graph-missing-pieces-audit.md acoustic_graph_proprioception: docs/acoustic-graph-proprioception.md pink_trombone_parity_fixtures: src/AquaSynth.Core/PinkTromboneParityFixtures.cs diff --git a/state/memory.json b/state/memory.json index 768caab..a23eaf1 100644 --- a/state/memory.json +++ b/state/memory.json @@ -59,6 +59,7 @@ "Faust-generated C# candidate rendering", "speech timing/confidence receipts for render requests, results, and checkpoints", "CultMesh speech render/scoring orchestration with payload manifests, peer/lease admission receipts, worker assignment, result collection, and central checkpoint application while the authority trainer owns optimizer steps and checkpoint commits", + "frozen IPA gesture experiment rounds with candidate scripts, primitive timelines, gesture-layer metrics, manifests, evidence JSONL, metric summaries, candidate clusters, and science briefs", "script scoring", "preset catalogs", "Faust emission and compiler wrapper" @@ -91,10 +92,10 @@ "Surge XT for modern hybrid synth modulation", "Cardinal/VCV-style patches for modular cable/rate semantics" ], - "rule": "For speech, add schema fields and learned-control lanes only when the parity harness has a loss surface that can exercise them. For reference synths, add DSL abstractions only when rebuilds prove the missing invariant. Parsing alone is inventory, not evidence of expressivity. Pink Trombone should be decomposed into reusable low-level Aqua primitives before audio golf, not copied as a bespoke clone or inflated into PT-shaped modules. After the 2026-05-29 proprioception correction, collapse graph-vocal lowering into a small set of instrumented physical primitives before more utterance golf. Gesture motion belongs in ControlSurface/ControlSpline timeline ownership, not primitive-local smoothing; cut any generated contact/port spline that invents motion not supported by primitive reference timelines. Public clients author gestures through ControlSurfaceCatalog plus ControlSplineTimeline and stream surface control dictionaries; higher-level gesture templates and phoneme_gesture are only spline emitters. IPA descriptors seed which anatomical surfaces move, while local datasets golf numeric spline defaults and patch voice code. Training reports must separate gesture_score, clean_vocal_score, and full_parity_score so full-patch recording-condition helpers cannot impersonate articulation." + "rule": "For speech, add schema fields and learned-control lanes only when the parity harness has a loss surface that can exercise them. For reference synths, add DSL abstractions only when rebuilds prove the missing invariant. Parsing alone is inventory, not evidence of expressivity. Pink Trombone should be decomposed into reusable low-level Aqua primitives before audio golf, not copied as a bespoke clone or inflated into PT-shaped modules. After the 2026-05-29 proprioception correction, collapse graph-vocal lowering into a small set of instrumented physical primitives before more utterance golf. Gesture motion belongs in ControlSurface/ControlSpline timeline ownership, not primitive-local smoothing; cut any generated contact/port spline that invents motion not supported by primitive reference timelines. Public clients author gestures through ControlSurfaceCatalog plus ControlSplineTimeline and stream surface control dictionaries; higher-level gesture templates and phoneme_gesture are only spline emitters. IPA descriptors seed which anatomical surfaces move, while local datasets golf numeric spline defaults and patch voice code. Training reports must separate gesture_score, clean_vocal_score, and full_parity_score so full-patch recording-condition helpers cannot impersonate articulation. Frozen IPA gesture rounds own candidate scripts, primitive timelines, gesture metrics, manifests, evidence receipts, metric summaries, candidate clusters, and science briefs; statistical science workers and audio parity stages consume those bundles without rewriting gesture evidence." }, "ipa_vocal_tract_path": { - "status": "This is now the active project center. Roadmap and research notes align the curriculum around structured utterance metadata -> learned utterance embedding -> learned synth automation -> vocal tract/envelope/LFO/filter/spectral controls -> rendered audio loss. The first Core contracts still defend the boundary: PhoneticIntent is the Weksa/language-owned handoff, ArticulatoryPlan is the AquaSynth realization layer, VocalTractMorphology declares anatomy capabilities, ArticulatoryConstraintReport is the host-visible veto surface, and VocalTractPlanResult is the tiny end-to-end proof artifact for host branching. IPA is an authoring input only: tokenization and feature mapping lower into language phonology profiles, timed articulatory gestures, morphology-specific tract/excitation curves, and Faust DSP. The staged support plan starts with tokenization and vowels, then core pulmonic consonants, expanded human IPA, airstream/phonation, and Weksa/alien morphologies. Optional eSpeak NG tests provide the first generated speech workout when ESPEAK_NG or espeak-ng is installed; eSpeak is intelligibility/timing/log-mel pressure, not anatomy truth. AquaSynth owns the learned utterance embedding encoder and synth driver: speech text embeddings plus prosody/emphasis hints plus Ghostlight/Epiphany-shaped character state vectors compress into utterance embeddings, and phonetic features plus that embedding feed a packed-buffer native C# backprop/Adam mapper that predicts tract, AM/FM, LFO, filter, and mel spectral-envelope controls. SpeechBackpropagationPipeline chains the two models: synth-driver target loss returns gradients with respect to its input, slices the utterance-embedding gradient, and updates the utterance encoder from downstream speech loss. The generated ground-truth training fixture renders eSpeak syllables, extracts log-mel evidence, and trains that chained pipeline toward eSpeak-seeded mel/control targets. CultMesh speech training now has payload manifests, peer/lease admission receipts, worker assignment, result collection, and central checkpoint application; workers do not own model updates. Real remote artifact chunk transfer and process supervision remain CultMesh infrastructure surfaces, not AquaSynth workaround territory.", + "status": "This is now the active project center. Roadmap and research notes align the curriculum around structured utterance metadata -> learned utterance embedding -> learned synth automation -> vocal tract/envelope/LFO/filter/spectral controls -> rendered audio loss. The first Core contracts still defend the boundary: PhoneticIntent is the Weksa/language-owned handoff, ArticulatoryPlan is the AquaSynth realization layer, VocalTractMorphology declares anatomy capabilities, ArticulatoryConstraintReport is the host-visible veto surface, and VocalTractPlanResult is the tiny end-to-end proof artifact for host branching. IPA is an authoring input only: tokenization and feature mapping lower into language phonology profiles, timed articulatory gestures, morphology-specific tract/excitation curves, and Faust DSP. The staged support plan starts with tokenization and vowels, then core pulmonic consonants, expanded human IPA, airstream/phonation, and Weksa/alien morphologies. Optional eSpeak NG tests provide the first generated speech workout when ESPEAK_NG or espeak-ng is installed; eSpeak is intelligibility/timing/log-mel pressure, not anatomy truth. AquaSynth owns the learned utterance embedding encoder and synth driver: speech text embeddings plus prosody/emphasis hints plus Ghostlight/Epiphany-shaped character state vectors compress into utterance embeddings, and phonetic features plus that embedding feed a packed-buffer native C# backprop/Adam mapper that predicts tract, AM/FM, LFO, filter, and mel spectral-envelope controls. SpeechBackpropagationPipeline chains the two models: synth-driver target loss returns gradients with respect to its input, slices the utterance-embedding gradient, and updates the utterance encoder from downstream speech loss. The generated ground-truth training fixture renders eSpeak syllables, extracts log-mel evidence, and trains that chained pipeline toward eSpeak-seeded mel/control targets. CultMesh speech training now has payload manifests, peer/lease admission receipts, worker assignment, result collection, and central checkpoint application; workers do not own model updates. Real remote artifact chunk transfer and process supervision remain CultMesh infrastructure surfaces, not AquaSynth workaround territory. IpaGestureExperiment now writes frozen descriptor/variant rounds with candidate scripts, primitive timelines, gesture metrics, manifests, and evidence JSONL, then analyzes them into metric summaries, score-band clusters, and a science brief so statistical sub-agents can inspect immutable evidence while foreground generation continues.", "lesson": "Do not build a complete IPA parser before the tract can say basic syllables. The durable machine is tokenizer -> feature mapper -> phonology profile -> gesture planner -> morphology -> tract plan -> Faust renderer, with dependency-injected seams and mocks at each boundary. Weksa should use IPA-like phonetic input without letting human IPA semantics own alien anatomy. Anatomy has veto power: if a morphology lacks bilabial closure or another required capability, AquaSynth reports that failure instead of smearing over it.", "next": "Start the next speech gradient descent pass from Weksa's emitted v0.1 seed batch at `E:\\Projects\\weksa\\examples\\speech-training\\tiny-panphon-v0.1\\batch.json`: 1024 bge-m3 semantic speech-text floats, variable-length PanPhon sequence evidence, 256 AquaSynth-owned phonetic-realization embedding floats from `aquasynth.panphon_sequence_encoder.v0.1`, 32 prosody/emphasis floats, 64 projected character-state floats, and 64 AquaSynth utterance-embedding output floats. Keep semantic text embeddings and phonetic realization separate. Next tighten the parity harness: load that batch into AquaSynth training records, render tiny utterance fixtures, sweep controller outputs through compiled Faust controls, score log-mel/timing/envelope loss, record per-stage decision time/latency/budget/confidence receipts, backpropagate into the utterance encoder plus synth driver, and connect Stage 0/1 IPA token spans, vowel feature bundles, and human baseline tract-area targets to that loop. For distributed work, use RunCultMeshTrainingStep as the boring authority path: admitted leased workers return gradients/results, then the trainer applies centrally. Do not attempt federated averaging until this path is exercised against real Faust-rendered speech jobs." }, @@ -121,8 +122,8 @@ }, "last_verified": { "command": "dotnet test tests\\AquaSynth.Dsl.Tests\\AquaSynth.Dsl.Tests.csproj --no-restore --disable-build-servers -p:UseSharedCompilation=false -p:BuildInParallel=false --filter \"FullyQualifiedName~PatchScriptTests\" -v minimal", - "result": "IPA training scoring contract documented. Gesture score is now specified as descriptor/spline/primitive-timeline evidence, separate from clean vocal and full parity scores. Earlier full unfiltered runs hit the five-minute wall after leaving orphan dotnet workers; focused suites are the current reliable verification path.", - "commit": "pending ipa training score docs" + "result": "IpaGestureExperiment frozen-round harness and science-brief analysis added and documented. PatchScriptTests pass 93/93. Earlier full unfiltered runs hit the five-minute wall after leaving orphan dotnet workers; focused suites are the current reliable verification path.", + "commit": "pending ipa gesture experiment harness" } } diff --git a/state/scratch.md b/state/scratch.md index 6d29ff3..0fa758a 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -2,6 +2,19 @@ Current slice: +- Added the first scalable IPA gesture experiment harness. + `IpaGestureExperiment.WriteRound` writes a frozen round bundle with + `manifest.yaml`, candidate `.aqua` scripts, primitive timeline CSVs from + `ProbeTimelineReport`, gesture-layer `metrics.csv`, and per-candidate + `evidence.jsonl`. `IpaGestureExperiment.AnalyzeRound` writes + `analysis/metric-summary.csv`, `analysis/candidate-clusters.csv`, and + `analysis/science-brief.md` for the science-worker handoff. The harness + scores only descriptor/spline/primitive evidence (`surface_coverage`, + `motion_direction`, `contour_timing`, `primitive_timeline`, + `gesture_score`) and explicitly does not own clean vocal identity, full + spectrogram parity, optimizer checkpoints, or worker orchestration. + Verification: `PatchScriptTests` pass 93/93. + - Documented the IPA training scoring contract. Gesture score is measured at the descriptor/spline/primitive-timeline layer using coverage, direction, contour/timing, primitive consequences, and optional external articulation diff --git a/state/spine.yaml b/state/spine.yaml index 0677430..114b40c 100644 --- a/state/spine.yaml +++ b/state/spine.yaml @@ -143,6 +143,7 @@ live_invariants: - Public gesture authoring API is now explicit. `ControlSurfaceCatalog.FromPatch(patch)` exposes normalized surface metadata for hosts; `ControlSplineTimeline` lets clients edit future points and emit `ControlValuesAt(t)` as ordinary surface-control dictionaries. Native Faust compiled patches carry `ControlSurfaces` and expose `ControlValuesAt(timeline,t)` to filter semantic timeline values to controls exported by the optimized DSP. This is the runtime path for user-authored gestures without recompilation. Verification: `PatchScriptTests` pass 91/91 and `NativeFaustRuntimeTests` pass 5/5. - First IPA/anatomy sugar is live. `phoneme_gesture` accepts known IPA symbols or explicit descriptors such as `descriptor=voiceless_labial-velar_fricative`, maps place/manner/voicing onto primary anatomical surfaces, and emits ordinary `ControlSpline`s. It is deterministic seed material for local reference-data golf, not exact articulatory truth. Patches may still use normal FM/AM/modulators/envelopes/filters around the anatomical control stream. Verification: `PatchScriptTests` pass 92/92. - IPA training scoring contract is documented. Reports must keep `gesture_score`, `clean_vocal_score`, and `full_parity_score` separate. Gesture score measures descriptor-to-surface coverage, motion direction, spline contour/timing, primitive timeline consequences, and optional external articulation landmarks. Full parity patches may use FM/AM/modulators/envelopes/filters, auxiliary animated voices, and recording-condition helpers, but those helpers cannot count as articulation evidence unless gesture and clean-vocal scores move coherently. + - `IpaGestureExperiment.WriteRound` is the first frozen batch harness for IPA hypothesis work. It writes `manifest.yaml`, candidate `.aqua` scripts, primitive `ProbeTimelineReport` CSVs, gesture-layer `metrics.csv`, and per-candidate `evidence.jsonl` under a caller-provided artifact root. `IpaGestureExperiment.AnalyzeRound` writes `analysis/metric-summary.csv`, `analysis/candidate-clusters.csv`, and `analysis/science-brief.md` for the science-worker handoff. This harness owns frozen descriptor/spline/primitive evidence only; clean vocal identity, full spectrogram parity, optimizer checkpoints, and worker orchestration stay downstream. Focused verification: `PatchScriptTests` pass 93/93. - TurbulenceJet now includes a release-timed burst-noise component in addition to the deterministic pressure pulse, but a stronger trial barely moved papa; the source is not the main remaining articulation bottleneck. Graph radiation now mixes 30% raw boundary flow with 70% high-passed flow after local admittance weighting, down from the over-bright 15/85 blend. Latest radiation/source artifact under `artifacts/parity/pink-trombone-utterance-logmel/20260527T174236049`: mama/papa/thrombosis cosine 0.6578/0.7692/0.5585, rmsRatio 3.0006/2.6153/2.3488, articulation 0.1437/0.1173/0.1191. Static `closure-release` under `artifacts/parity/pink-trombone-logmel/20260527T174139661` has rmsRatio 0.9900 and speechBandRatio 0.0842. This is still not speaking; next pressure is true tract resonance/passive scattering and pressure storage, not more burst gain. - Same-path two-port area discontinuities now emit `graph_area_energy_in_*` and `graph_area_energy_out_*` probes alongside the three-port branch `graph_connection_energy_*` probes. Use these to inspect passivity and formant-body failures at the scatter sites rather than judging only final output loudness. - `FaustExportOptions.DebugProbeUi` wraps graph probe signals in Faust `vbargraph` UI controls under `/debug/...` without changing audio output arity. Native streaming Faust patches now separate writable controls from read-only probe zones and can read/snapshot probe values after `ProcessBlock`; use this for acoustic graph passivity/radiation inspection, leave it off for normal parity renders. diff --git a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs index 7594e4c..86fb3b1 100644 --- a/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs +++ b/tests/AquaSynth.Dsl.Tests/PatchScriptTests.cs @@ -443,6 +443,63 @@ public sealed class PatchScriptTests Assert.True(fricativeControls["/vocal/sources/0/noise"] > nasalControls["/vocal/sources/0/noise"]); } + [Fact] + public void IpaGestureExperimentWritesFrozenRoundBundle() + { + var root = Path.Combine(Path.GetTempPath(), $"aquasynth-ipa-round-{Guid.NewGuid():N}"); + var result = IpaGestureExperiment.WriteRound( + root, + "round-test", + [ + new IpaGestureExperimentTarget("bilabial-stop", "p", "voiceless_bilabial_plosive", .14f), + new IpaGestureExperimentTarget("nasal", "m", "voiced_bilabial_nasal", .18f) + ], + [ + new IpaGestureExperimentVariant("base", 1, 1, ["seed"]), + new IpaGestureExperimentVariant("slow-soft", .75f, 1.35f, ["timing"]) + ], + timelineBlocks: 8); + + Assert.True(File.Exists(result.ManifestPath)); + Assert.True(File.Exists(result.MetricsPath)); + Assert.True(File.Exists(result.EvidencePath)); + Assert.Equal(4, result.Candidates.Count); + Assert.Equal(20, result.Metrics.Count); + + foreach (var candidate in result.Candidates) + { + Assert.True(File.Exists(candidate.ScriptPath)); + Assert.True(File.Exists(candidate.TimelinePath)); + Assert.Contains(candidate.Tags, tag => tag.StartsWith("descriptor:", StringComparison.Ordinal)); + } + + var metrics = File.ReadAllText(result.MetricsPath); + Assert.StartsWith("candidate_id,target_id,layer,metric,value", metrics, StringComparison.Ordinal); + Assert.Contains(",gesture,gesture_score,", metrics, StringComparison.Ordinal); + Assert.Contains(",gesture,primitive_timeline,", metrics, StringComparison.Ordinal); + Assert.All(result.Metrics, metric => Assert.InRange(metric.Value, 0, 1)); + + var manifest = File.ReadAllText(result.ManifestPath); + Assert.Contains("does_not_own: clean vocal audio identity", manifest, StringComparison.Ordinal); + + var evidence = File.ReadAllText(result.EvidencePath); + Assert.Contains("\"gesture_score\":", evidence, StringComparison.Ordinal); + Assert.DoesNotContain("full_parity_score", evidence, StringComparison.Ordinal); + + var analysis = IpaGestureExperiment.AnalyzeRound(result); + Assert.True(File.Exists(analysis.ScienceBriefPath)); + Assert.True(File.Exists(analysis.MetricSummaryPath)); + Assert.True(File.Exists(analysis.CandidateClustersPath)); + Assert.NotEmpty(analysis.MetricSummaries); + Assert.NotEmpty(analysis.CandidateClusters); + Assert.Contains(analysis.MetricSummaries, summary => summary.Metric == "gesture_score" && summary.Spread >= 0); + + var brief = File.ReadAllText(analysis.ScienceBriefPath); + Assert.Contains("Score Surface", brief, StringComparison.Ordinal); + Assert.Contains("Candidate Clusters", brief, StringComparison.Ordinal); + Assert.Contains("frozen gesture-layer evidence only", brief, StringComparison.Ordinal); + } + [Fact] public void PrimitiveProbeTimelineReportsFlowBeforeAudioParity() {