You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Praat脚本开发:提取音节层与重音层并实现自定义修改

Fixed Praat Script for Syllable-Accent Extraction

Got it, let's get your Praat script working correctly to extract syllables and their corresponding accent marks. The main issues in your original script were incorrect interval time handling and unreliable accent matching—here's the corrected version that addresses those:

writeInfo: ""  # Clear the output buffer first
selectObject: "TextGrid example"

# Define your tier indices clearly (easier to adjust later)
syllable_tier = 1
accent_tier = 2

# Get the total number of syllable intervals to loop through
total_syllables = Get number of intervals: syllable_tier

for i from 1 to total_syllables
    # Grab the syllable label and its full time interval
    syllable$ = Get label of intervals: syllable_tier, i
    syllable_start = Get start time of interval: syllable_tier, i
    syllable_end = Get end time of interval: syllable_tier, i
    
    # Check if there are any accent points within this syllable's time window
    accent_count = Get number of points in interval: accent_tier, syllable_start, syllable_end
    
    if accent_count == 0
        # No accent found for this syllable
        appendInfoLine: syllable$, " ", "no"
    else
        # Get the first accent point in the interval (adjust index if multiple points are expected)
        accent_time = Get time of point in interval: accent_tier, syllable_start, syllable_end, 1
        accent$ = Get label of point: accent_tier, accent_time
        
        # Filter out unwanted accent markers (- or %) as per your original logic
        if accent$ == "-" or accent$ == "%"
            appendInfoLine: syllable$, " ", "no"
        else
            appendInfoLine: syllable$, " ", accent$
        endif
    endif
endfor

What Changed & Why:

  • Fixed Interval Time Retrieval: The original Get time of interval command doesn't exist in Praat. Instead, we use Get start time of interval and Get end time of interval to capture the full duration of each syllable—this is crucial for accurately matching accents that fall anywhere within the syllable's window.
  • Reliable Accent Matching: Instead of checking for an accent at an exact time (which almost never happens in real annotations), we count how many accent points lie within the syllable's interval. This ensures we don't miss valid accents.
  • Cleaned Up Syntax: Removed invalid #if comments (Praat uses standard if statements) and added clear variable names to make the script easier to tweak later.
  • Handled Edge Cases: Added checks to treat - and % as "no" accent, aligning with your original intended logic.

When you run this script, it will output exactly the format you need—each syllable paired with its accent mark or "no" if no valid accent exists.

内容的提问来源于stack exchange,提问作者dgr379

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 07:36:23