Latent Space Navigation β€” User Guide

Learns a latent space from event-level audio patches (on-the-fly autoencoder), then navigates that space to generate a new timeline by selecting/morphing events along a deterministic latent trajectory. The result sounds like traveling through hidden acoustic identities.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.0 (2025) License: MIT License Citation: Cohen, S. (2025). Praat AudioTools Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script implements a Latent Space Navigation engine β€” an AI-powered tool that learns a latent space from event-level audio patches using an on-the-fly autoencoder, then navigates that space to generate a new timeline by selecting or morphing events along a deterministic latent trajectory. The result sounds like traveling through hidden acoustic identities.

🧭 What is Latent Space Navigation?

This approach treats each audio event as a point in a learned low-dimensional space:

  • Events are segmented from the source (200ms–3s)
  • Autoencoder learns to compress each event into a latent vector (2–32 dimensions)
  • Navigation generates a path through this latent space (ThermoDrift, Attractor, Convection, or 2D Mixer)
  • Selection picks events nearest to the path; Morphing crossfades between them
  • The result is a new timeline that "travels" through the discovered acoustic identities

Key Features:

Technical Implementation: (1) Event Segmentation: Praat segments audio using intensity peaks. (2) Mel Patches: Python extracts 40Γ—32 log-mel patches per event. (3) Autoencoder: MLP with hidden layer, leaky ReLU, denoising, L2 reg, Adam. (4) Latent Encoding: Z = encode(patches). (5) Navigation: Generate path through latent space. (6) Reconstruction: Select/morph events, crossfade concatenation. (7) Stats & Visualization.

Quick start

  1. In Praat, select exactly one Sound object (any duration, any content).
  2. Run script… β†’ select latent_navigation.praat.
  3. Choose Preset (2-7 for specific strategies, 1 for custom).
  4. Set autoencoder parameters (learning steps, latent size, seed).
  5. Choose navigation mode, path type, and adjust travel speed/dwell/smoothing.
  6. Select output mode (Selector/Morph) and target duration mode.
  7. Set event density (events per second).
  8. Enable Draw_visualization for analysis display.
  9. Click OK β€” engine segments, trains autoencoder, navigates, reconstructs.
Quick tip: Start with Gentle Drift preset on a 10-20 second recording with varied texture. Enable visualization β€” you'll see event boundaries (red lines) on the input waveform, and navigation statistics. Listen to how the output travels through the latent space, selecting different events along the path. The output appears as "source_nav" in the Objects window.
Important: PYTHON DEPENDENCIES β€” Requires numpy, soundfile, scipy (no scikit-learn). AUTOENCODER TRAINING happens on-the-fly and may take 30-60 seconds. EVENT SEGMENTATION uses intensity peaks β€” if your material has few dynamic changes, consider a different source. LATENT SIZE affects representation β€” too small may lose detail, too large may overfit. DENSITY controls output granularity β€” higher = more events per second.

Latent Navigation Theory

Autoencoder Architecture

Input: log-mel patch (40 mel bands Γ— 32 frames = 1280 features) Encoder: input (1280) β†’ hidden (h) β†’ latent (L) Decoder: latent (L) β†’ hidden (h) β†’ output (1280) where h = max(LΓ—2, min(256, √(1280Γ—L))) (geometric mean scaling) Activations: leaky ReLU (Ξ±=0.01) for hidden layers, linear for output Training: β€’ Denoising: add Gaussian noise (Οƒ=0.3, decaying) β€’ Loss: MSE against clean target β€’ L2 regularization: 1e-4 β€’ Optimizer: Adam (β₁=0.9, Ξ²β‚‚=0.999, Ξ΅=1e-8) β€’ Learning rate: 0.003, decaying

Latent Temperature

For each event, temperature T(i) combines reconstruction novelty and latent isolation: T(i) = 0.5 Γ— norm(recon_error[i]) + 0.5 Γ— norm(kNN_mean_dist[i]) where kNN_mean_dist[i] = average distance to 3 nearest neighbors in latent space. Temperature guides navigation speed (ThermoDrift) and event importance.

Navigation Modes

LRU Event Selection

At each step, select event minimizing: score = distance_to_path + LRU_penalty LRU_penalty[i] = (3 - recency) Γ— 0.5 Γ— max_distance (if recency < 3) This prevents the same event from being chosen repeatedly.

Output Modes

🎯 Selector Mode

At each step, pick the nearest event to the path point. Concatenate chosen events with equal-power crossfades.

Smoothing: for latent jumps > 0.5Γ—max_dist, apply gentle fade-in to reduce abruptness.

πŸ”„ Morph Mode

For each step, crossfade between current event and next event, weighted by latent distance:

weight = min(0.5, d/max_dist Γ— smoothing) morphed = (1-weight)Γ—clip_a + weightΓ—clip_b

Duration Control

ModeFormula
Preservetarget_dur = original_duration
Expandtarget_dur = original_duration Γ— 1.5
Compresstarget_dur = original_duration Γ— 0.6

Output event count = target_dur Γ— density

Preset Strategies

Preset 2: Gentle Drift

🌱 Subtle Latent Travel

Learning: 80 steps, latent=6 | Nav: Trajectory/ThermoDrift

Speed: 0.3 | Dwell: 0.5 | Smooth: 0.5

Output: Selector | Density: 2.5 ev/s

Character: Gentle drift through latent space β€” subtle, smooth evolution

Use on: Ambient, pads, subtle variations

Preset 3: Deep Attractors

🧲 Pole-Hopping

Learning: 150 steps, latent=12 | Nav: Trajectory/Attractor

Speed: 0.4 | Dwell: 0.7 | Smooth: 0.3

Output: Selector | Density: 3.0 ev/s

Character: Moves between attractor poles, dwelling at each β€” creates clear sections

Use on: Sectional forms, narrative structures

Preset 4: Convection Flow

🌊 Rising/Sinking Flow

Learning: 120 steps, latent=10 | Nav: Trajectory/Convection

Speed: 0.6 | Dwell: 0.3 | Smooth: 0.4

Output: Selector | Density: 3.5 ev/s

Character: Flow along principal axis β€” hot events rise, cool sink β€” creates directional motion

Use on: Evolving textures, risers, builds

Preset 5: Fast Scatter

πŸ’¨ Rapid Dispersion

Learning: 100 steps, latent=8 | Nav: Trajectory/ThermoDrift

Speed: 1.2 | Dwell: 0.1 | Smooth: 0.2

Duration: Expand (1.5Γ—) | Density: 5.0 ev/s

Character: Fast, scattered navigation β€” many events, rapid changes

Use on: Glitch, chaotic textures, fast variations

Preset 6: Slow Morph

🌈 Crossfaded Transitions

Learning: 150 steps, latent=10 | Nav: Trajectory/Attractor

Speed: 0.3 | Dwell: 0.6 | Smooth: 0.8

Output: Morph | Density: 2.0 ev/s

Character: Slow morphing between events β€” smooth latent transitions

Use on: Ambient morphs, gradual transformations

Preset 7: Dense Mixer

πŸŽ›οΈ 2D Plane Sweep

Learning: 100 steps, latent=8 | Nav: Mixer

Speed: 0.5 | Dwell: 0.3 | Smooth: 0.5

Output: Selector | Density: 4.0 ev/s

Character: 2D spiral sweep through reduced latent space β€” dense, exploratory

Use on: Dense textures, exploration, complex material

Parameters & Controls

Autoencoder Parameters

ParameterDefaultDescription
Learning_steps100Training iterations (10–500)
Latent_size8Bottleneck dimensions (2–32)
Seed42For reproducibility

Navigation Parameters

ParameterDefaultDescription
Navigation_modeTrajectoryTrajectory (1D path) or Mixer (2D plane)
Path_typeThermoDriftThermoDrift, Attractor, Convection (Trajectory mode)
Travel_speed0.5Speed of latent movement (0.1–2.0)
Dwell_amount0.3Time spent at attractor poles / dwell regions (0–1)
Smoothing0.4Fade strength for latent jumps / morph blending (0–1)

Output Parameters

ParameterDefaultDescription
Output_modeSelectorSelector (nearest event) or Morph (crossfade blend)
Target_durationPreservePreserve, Expand (1.5Γ—), Compress (0.6Γ—)
Density_(events_per_s)3.0Events per second in output (0.5–20.0)
Draw_visualization1Generate 5-panel display
Play_result1Audition after processing

Visualization & Analysis

5-Panel Display

Latent Space Navigation Visualization: Panel 1: TITLE β€’ Script name, source name, preset, nav mode/path type/output mode Panel 2: INPUT WAVEFORM β€’ Gray waveform with red dotted lines = event boundaries β€’ Title: "Original (N events)" Panel 3: OUTPUT WAVEFORM β€’ Blue waveform = navigated output β€’ Title: "Navigated" β€’ X-axis: Time (s) Panel 4: ORIGINAL SPECTROGRAM β€’ 0-5000 Hz spectrogram of original β€’ Title: "Original spectrogram" Panel 5: OUTPUT SPECTROGRAM β€’ 0-5000 Hz spectrogram of navigated output β€’ Title: "Navigated spectrogram" Panel 6: NAVIGATION STATS β€’ Steps, unique events used, repetition rate β€’ Avg latent travel distance β€’ Most-used events (IDs and usage counts) Panel 7: INTENSITY COMPARISON β€’ X-axis: Time, Y-axis: dB β€’ Gray line = original intensity β€’ Blue line = navigated intensity β€’ Title: "Intensity: Grey = original | Blue = navigated" Panel 8: SUMMARY PANEL β€’ Navigation mode/path/output, mean temperature β€’ Autoencoder loss (initial β†’ final) β€’ Duration, density, seed β€’ RMS comparison β€’ Warnings if any

Reading Navigation Stats

What the numbers mean:
  • Steps: Number of events in output timeline
  • Unique events used: How many distinct source events were selected
  • Repetition rate: (steps - unique)/steps β€” how often events repeat
  • Avg latent travel: Average distance moved in latent space per step
  • Mean temperature: Average of temperature field (0=cold, 1=hot)
  • Most used events: IDs of the 3 most frequently selected events

Applications

Electroacoustic Composition

Use case: Creating new timelines that explore the latent structure of source material

Technique: Deep Attractors or Convection Flow presets

Workflow:

Sound Design for Media

Use case: Creating evolving textures, transitions, risers

Technique: Slow Morph or Fast Scatter on appropriate sources

Applications:

Music Production

Use case: Creating variations, remixes, or generative parts

Technique: Different seeds and presets on same source

Examples:

Research & Education

Use case: Studying autoencoder latent spaces, navigation strategies

Technique: Compare path types on same source, examine most-used events

Learning outcomes:

Practical Workflow Examples

Troubleshooting Common Issues

Problem: Python not found or missing packages
Cause: Python not installed, or packages missing
Solution: Install Python and required packages: pip install numpy soundfile scipy
Problem: Too few events detected
Cause: Source has few intensity peaks, or segmentation parameters inappropriate
Solution: Use source with more dynamic variation, or adjust min/max event duration in script
Problem: Autoencoder loss not decreasing
Cause: Too few steps, too small latent size, or data too complex
Solution: Increase learning_steps, increase latent_size, or use simpler source
Problem: Output has clicks
Cause: Crossfade insufficient at splice points
Solution: Increase XFADE_SEC in Python script (currently 8ms)
Problem: Repetition rate very high
Cause: Too few events for given density, or LRU penalty too low
Solution: Reduce density, or increase LRU penalty in Python

Advanced Techniques

Custom path types:

In Python, modify _path_thermodrift(), _path_attractor(), or _path_convection() to implement new navigation strategies.

Autoencoder architecture tuning:

Modify hidden layer size calculation or add more layers for deeper networks.

Temperature redefinition:

Change temperature calculation in encode_events() to emphasize different acoustic properties.

Multi-channel audio:

The script preserves multichannel audio throughout β€” mel patches from mono mix, but reconstruction maintains original channels.