Extract Segment — User Guide
Precise audio segmentation: extracts defined time intervals from sound objects with multiple selection and processing options.
What this does
This script implements precise audio segmentation — extracting defined time intervals from sound objects with multiple selection and processing options. Key capabilities: (1) Multiple selection: Extract from multiple sound objects simultaneously. (2) Flexible time specification: Absolute times, percentages, or marker-based. (3) Overlap handling: Extract overlapping segments with fade options. (4) Batch processing: Process multiple intervals in one operation. Process copies selected time region from source sound, applies optional fade in/out, creates new sound object with extracted segment. Result: cleanly extracted audio segments ready for further analysis or composition.
Key Features:
- Multiple Selection — Extract from multiple sounds simultaneously
- Flexible Time Input — Absolute times, percentages, or relative markers
- Overlap Options — Handle overlapping segments with crossfade
- Batch Extraction — Process multiple intervals in one operation
- Fade In/Out — Apply smooth transitions at segment boundaries
- Preserve Metadata — Optional retention of original annotations
Technical Implementation: (1) Input validation: Check time boundaries against sound duration. (2) Time conversion: Convert percentage/marker inputs to absolute times. (3) Boundary alignment: Adjust to nearest zero-crossing if requested. (4) Extraction: Copy samples from start to end time. (5) Fade application: Apply cosine-shaped fades at boundaries. (6) Object creation: Create new Sound object with extracted samples. (7) Metadata handling: Copy relevant annotations if enabled. (8) Batch processing: Loop through multiple intervals/sounds. Key insight: Flexible time specification allows different workflow approaches (absolute times for precision, percentages for relative extraction, markers for annotation-based work).
Quick start
- In Praat, select one or more Sound objects.
- Run script… →
extract_segment.praat. - Choose time specification mode: Absolute, Percentage, or Marker-based.
- Enter start time and end time (or percentages/markers).
- Set fade in and fade out durations (optional).
- Enable zero-crossing alignment to avoid clicks at boundaries.
- Choose output naming convention for extracted segments.
- Click OK — segments extracted, named per convention.
Extraction Modes
Mode 1: Absolute Time Extraction
⏱️ Precise Time-Based Control
Specification: Start and end times in seconds
Parameters: Start time (s), End time (s)
Character: Absolute precision, independent of duration
Best for: Known time intervals, scripted extraction, research protocols
Example scenarios:
| Scenario | Start Time | End Time | Result |
|---|---|---|---|
| Extract first second | 0.0 | 1.0 | 0.0–1.0 segment |
| Extract from 2.5–4.2s | 2.5 | 4.2 | 2.5–4.2 segment |
| Extract last 500ms | duration-0.5 | duration | Last half-second |
| Multiple intervals | 0, 2, 4 | 1, 3, 5 | Three segments |
Mode 2: Percentage-Based Extraction
📊 Relative Duration Control
Specification: Start and end percentages of total duration
Parameters: Start (%), End (%)
Character: Relative to sound length, adaptable
Best for: Variable-length sounds, proportional extraction
Example scenarios:
| Scenario | Start % | End % | Result |
|---|---|---|---|
| Extract first half | 0 | 50 | 0%–50% segment |
| Extract middle third | 33.33 | 66.66 | Middle third |
| Extract last quarter | 75 | 100 | Last quarter |
| Exclude first/last 10% | 10 | 90 | Middle 80% |
Mode 3: Marker-Based Extraction
📍 Annotation-Driven Control
Specification: Based on TextGrid interval boundaries
Parameters: Tier number, Interval label(s)
Character: Annotation-aware, semantic extraction
Best for: Phonetic analysis, labeled datasets, annotation workflows
Example scenarios:
| Scenario | Tier | Label | Result |
|---|---|---|---|
| Extract all "s" sounds | 1 (phone) | s | All /s/ segments |
| Extract vowel intervals | 2 (vowel) | a, e, i, o, u | All vowel segments |
| Extract specific word | 3 (word) | hello | All "hello" instances |
| Extract pause regions | 4 (pause) | sil, sp | All silence/pause regions |
Parameters & Options
Core Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| time_mode | option | Absolute | Time specification method |
| start_time | text | 0.0 | Start time/percentage/marker |
| end_time | text | 1.0 | End time/percentage/marker |
| fade_in | real | 0.0 | Fade-in duration (seconds) |
| fade_out | real | 0.0 | Fade-out duration (seconds) |
| align_zero | boolean | yes | Align to zero-crossings |
| preserve_annotations | boolean | no | Copy TextGrid annotations |
| naming_convention | text | %original%_seg%index% | Output naming pattern |
Time Mode Specific Parameters
| Mode | Parameter | Default | Description |
|---|---|---|---|
| Absolute | times_in_seconds | true | Input in seconds |
| Percentage | round_percentages | true | Round to nearest 0.1% |
| Marker | textgrid_tier | 1 | TextGrid tier number |
| Marker | interval_labels | * | Labels to extract (* = all) |
Advanced Parameters
| Parameter | Default | Description |
|---|---|---|
| buffer_before | 0.0 | Add buffer before segment (s) |
| buffer_after | 0.0 | Add buffer after segment (s) |
| min_duration | 0.0 | Minimum segment duration (s) |
| max_duration | 0.0 | Maximum segment duration (s) |
| overlap_action | skip | How to handle overlapping intervals |
Advanced Features
Batch Processing
🔄 Multiple Interval Extraction
Feature: Extract multiple segments in one operation
Syntax: Comma-separated time pairs
Example: start_times = "0, 2, 4", end_times = "1, 3, 5"
Result: Three segments: 0-1s, 2-3s, 4-5s
Zero-Crossing Alignment
↕️ Click-Free Boundaries
Purpose: Avoid audible clicks at segment boundaries
Method: Adjust times to nearest zero-crossing point
Effect: Smoother transitions, especially with no fade
Trade-off: Slight time shift (typically < 0.5ms)
Fade Application
Fade types:
Overlap Handling Strategies
| Strategy | Action | Use Case |
|---|---|---|
| skip | Skip overlapping intervals | Clean extraction, no duplicates |
| merge | Merge into single segment | Continuous regions |
| crossfade | Apply crossfade in overlap | Smooth transitions |
| separate | Extract as separate segments | All instances needed |
Naming Convention Placeholders
Applications
Phonetic Research
Use case: Extract specific phone segments for analysis
Technique: Marker mode with phone-tier labels
Workflow:
- Annotate sounds in TextGrid (phone tier)
- Select sound + TextGrid objects
- Run extract with label filter (e.g., "s" for /s/ sounds)
- Extract all matching segments automatically
Music Sampling
Use case: Create sample library from recordings
Technique: Batch extraction with multiple intervals
Example: Extract individual drum hits, instrument notes, vocal phrases
Advanced: Use naming convention with musical properties (note, velocity, etc.)
Stimulus Preparation
Use case: Create experimental stimulus sets
Requirements: Precise durations, consistent boundaries
Technique: Absolute time mode with validation
Quality control: Zero-crossing alignment + short fades for smooth edges
Podcast/Audio Editing
Use case: Remove sections, extract highlights
Technique: Percentage mode for relative editing
Example: Remove first/last 10%, extract middle 80% as "highlight reel"
Efficiency: Batch process multiple episodes
Archival Segmentation
Use case: Split long recordings into manageable chunks
Technique: Regular interval extraction
Example: Extract 5-minute segments from 2-hour recording
Automation: Script to extract at fixed intervals
Practical Workflow Examples
🔬 Phonetic Analysis (Research)
Goal: Extract all instances of /t/ sounds for analysis
Settings:
- Time mode: Marker-based
- Tier: 1 (phone tier)
- Labels: t, tʰ (aspirated t)
- Buffer: 0.02 s before/after
- Align zero: yes
Result: All /t/ segments extracted with 20ms context
🎵 Drum Sample Extraction (Music Production)
Goal: Create kick drum sample library
Settings:
- Time mode: Absolute
- Intervals: "0.5, 2.3, 4.1" to "0.8, 2.6, 4.4"
- Fade out: 0.05 s
- Naming: "kick_%index%"
Result: Three kick drum samples with short fade-out
🎤 Podcast Highlight Clips (Editing)
Goal: Extract best moments for promo
Settings:
- Time mode: Percentage
- Intervals: "15, 45, 70" to "25, 55, 80" (%)
- Fade in/out: 0.1 s
- Naming: "highlight_%index%"
Result: Three 10% segments from different parts
Troubleshooting Common Issues
Cause: End time > sound duration
Solution: Check time values, use duration-0.1 for end if needed
Cause: Boundaries not at zero-crossing
Solution: Enable zero-crossing alignment, add short fades
Cause: No TextGrid selected or tier doesn't exist
Solution: Select both Sound and TextGrid, check tier number
Cause: Time list mismatch or overlap handling
Solution: Verify start/end lists have same count, check overlap_action