Constraint-Based Duration Control — User Guide

Silence-based segmentation followed by weighted duration optimization: each sounding interval is moved continuously between its original duration and a common target, then resynthesized through a piecewise DurationTier.

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

What this does

Constraint-Based Duration Control detects sounding and silent regions, assigns every sounding interval a new target duration according to two weighted constraints, and uses a Praat DurationTier to realize the timing change.

The two constraints are:

The weights determine the compromise continuously. There is no longer a finite set of three duration candidates: the current implementation calculates the exact minimum of its weighted squared-violation objective.

OT, Harmonic Grammar & this script

Optimality Theory (OT) is a constraint-based framework in which candidate outputs are evaluated by a hierarchy of violable constraints. Classical OT uses ranked constraints: satisfying a higher-ranked constraint takes priority over lower-ranked constraints.

Harmonic Grammar (HG) is closely related but uses numerical constraint weights. A candidate's weighted violations are combined into a single score or harmony value.

This script is best understood as OT-inspired, Harmonic-Grammar-style optimization. It uses the OT vocabulary of TARGET and FAITHFULNESS, but the constraints are numerical weights rather than a strict ranking. It also uses a continuous closed-form duration solution rather than choosing among a discrete candidate set.

Quick start

  1. Select exactly one mono or stereo Sound object.
  2. Run Constraint-Based_Duration_Control.praat.
  3. Choose a preset or keep Custom.
  4. For Custom, set Weight_target_duration, Weight_faithfulness, and Target_duration_s.
  5. Adjust the silence-detection settings if the automatic segmentation does not match the source.
  6. Run the script. The result is named <source>_OT.

Segmentation

Segmentation is created with Praat's To TextGrid (silences). For stereo input, the script first makes a mono fold for analysis only.

To TextGrid (silences): minimum pitch = Min_pitch_Hz time step = 0.0 (automatic) silence threshold = Silence_threshold_dB minimum silent interval = Min_silent_interval_s minimum sounding interval = Min_sounding_interval_s labels = "silent" / "sounding"

The silence threshold is relative to the maximum intensity used by Praat's silence-detection procedure. Only intervals labelled sounding receive non-unity duration ratios. If no sounding interval is found, the script stops and asks for different segmentation settings.

Weighted duration solution

For an original sounding duration O, target duration T, target weight Wt, and faithfulness weight Wf, the script minimizes:

J(d) = Wt × (d - T)^2 + Wf × (d - O)^2

The exact minimum is:

d* = (Wt × T + Wf × O) / (Wt + Wf)

Therefore the new duration is a weighted average of target and original duration:

The local duration ratio used by Praat is:

ratio = d* / O

A ratio below 1 shortens that sounding interval; a ratio above 1 lengthens it.

DurationTier construction

A Praat DurationTier is linearly interpolated between its points. A single point at the middle of each interval would therefore smear one duration ratio across neighbouring material. The script instead constructs an approximately piecewise-constant tier.

For every sounding interval, it places points immediately around the left and right boundaries:

just before sounding start: 1.0 just inside sounding start: ratio just inside sounding end: ratio just after sounding end: 1.0

The transition width is at most 1 microsecond on each edge (min(0.000001, intervalDuration / 4)). Silent regions therefore remain at duration factor 1.0 apart from these negligible boundary transitions.

Before resynthesis, the script asks the DurationTier for its exact implied target duration. This is reported as Predicted duration and compared with the actual resynthesized duration.

Presets

PresetWtWfTargetWeighted behavior
Staccato5.00.50.20 sAbout 91% target + 9% original.
Legato1.00.50.80 sAbout 67% target + 33% original.
Strict Timing10.00.10.40 sAbout 99% target + 1% original.
Natural0.15.00.40 sAbout 2% target + 98% original.
Balanced2.01.00.40 sAbout 67% target + 33% original.

Named presets overwrite only the two weights and the target duration. Segmentation, visualization, and playback settings remain as entered in the form.

Parameters

ParameterDefaultBehavior
PresetCustomCustom plus five named duration-weight presets.
Weight_target_duration2.0Non-negative TARGET weight.
Weight_faithfulness1.0Non-negative FAITHFULNESS weight.
Target_duration_s0.4 sPositive target duration shared by all sounding intervals.
Min_pitch_Hz100 HzUsed by silence detection and as the Manipulation pitch floor; must be >0 and <600 Hz.
Silence_threshold_dB-25 dBRelative silence threshold used by To TextGrid (silences).
Min_silent_interval_s0.1 sMinimum silent interval; may be zero.
Min_sounding_interval_s0.1 sMinimum sounding interval; may be zero.
Draw_visualizationOnDraws the current suite visualization.
Play_resultOnPlays the resulting Sound.
At least one of the two constraint weights must be greater than zero. The script supports mono or stereo Sounds only.

Mono & stereo behavior

Segmentation always uses a mono analysis signal. For mono input, the original channel is resynthesized directly.

For stereo input, the original left and right channels are extracted and each is independently converted to a Manipulation object using the same DurationTier. The two resynthesized channels are then recombined in their original L/R order. This preserves stereo channel identity while keeping their duration mapping aligned.

The Manipulation analysis uses a 10 ms time step, Min_pitch_Hz as pitch floor, and a fixed 600 Hz pitch ceiling.

Visualization

When enabled, the Picture window shows four components:

The Source and Output waveforms use a shared amplitude scale.

Output & practical limits