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.
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:
- TARGET: prefer the user-specified target duration.
- FAITHFULNESS: prefer the interval's original duration.
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.
Quick start
- Select exactly one mono or stereo Sound object.
- Run
Constraint-Based_Duration_Control.praat. - Choose a preset or keep Custom.
- For Custom, set Weight_target_duration, Weight_faithfulness, and Target_duration_s.
- Adjust the silence-detection settings if the automatic segmentation does not match the source.
- 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.
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:
The exact minimum is:
Therefore the new duration is a weighted average of target and original duration:
- Wt = 0: exact faithfulness,
d* = O. - Wf = 0: exact target,
d* = T. - Both positive: a continuous weighted compromise.
The local duration ratio used by Praat is:
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:
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
| Preset | Wt | Wf | Target | Weighted behavior |
|---|---|---|---|---|
| Staccato | 5.0 | 0.5 | 0.20 s | About 91% target + 9% original. |
| Legato | 1.0 | 0.5 | 0.80 s | About 67% target + 33% original. |
| Strict Timing | 10.0 | 0.1 | 0.40 s | About 99% target + 1% original. |
| Natural | 0.1 | 5.0 | 0.40 s | About 2% target + 98% original. |
| Balanced | 2.0 | 1.0 | 0.40 s | About 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
| Parameter | Default | Behavior |
|---|---|---|
| Preset | Custom | Custom plus five named duration-weight presets. |
| Weight_target_duration | 2.0 | Non-negative TARGET weight. |
| Weight_faithfulness | 1.0 | Non-negative FAITHFULNESS weight. |
| Target_duration_s | 0.4 s | Positive target duration shared by all sounding intervals. |
| Min_pitch_Hz | 100 Hz | Used by silence detection and as the Manipulation pitch floor; must be >0 and <600 Hz. |
| Silence_threshold_dB | -25 dB | Relative silence threshold used by To TextGrid (silences). |
| Min_silent_interval_s | 0.1 s | Minimum silent interval; may be zero. |
| Min_sounding_interval_s | 0.1 s | Minimum sounding interval; may be zero. |
| Draw_visualization | On | Draws the current suite visualization. |
| Play_result | On | Plays the resulting Sound. |
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.
Visualization
When enabled, the Picture window shows four components:
- Source: mono display copy of the source with sounding-interval boundaries.
- Weighted duration solution: one vertical comparison per sounding interval. Gray = original duration, red dotted line = common target, blue = exact weighted solution.
- Output: mono display copy of the resynthesized result.
- Summary: preset, target, weights, number of sounding intervals, ratio mean/range, original/result duration, and prediction error.
The Source and Output waveforms use a shared amplitude scale.
Output & practical limits
- The result is named
<source name>_OT. - There is no final peak normalization or safety ceiling in this script.
- The script changes duration through Praat Manipulation resynthesis; it does not deliberately transpose pitch.
- The requested local timing is controlled by the DurationTier; actual waveform quality depends on Praat's pitch/pulse analysis and overlap-add resynthesis.
- Very large duration ratios may produce audible resynthesis artifacts, especially when pitch tracking is difficult.
- The original Sound remains unchanged.