0

我正在尝试为 Praat 编写一个脚本,但很难做到。

我想要的是在一个句子(和一个声音)中对某个单词有一个结果,例如:因为你现在不使用你的车,我可以借用它吗?

我想要一个“时刻”这个词的音调列表。如果我选择单词“moment”并在音高菜单下选择音高列表,那么它会给我每 0.01 秒的时间和 f0(打开声音和 TextGrid)。

我一直在搜索并尝试编写此脚本,但尚未成功。

你能帮我解决这个问题吗?


我已经修改了上面的问题。

句子:因为你现在不用你的车,我可以借一下吗? (我有一个 mp3 文件,这个句子有 2 层的文本网格,第 1 层是单词,第 2 层是电话)

以下是我的脚本。我想为单词“moment”的最后一个音节部分设置 f0 最大值和最小值,但只成功地在整个间隔 10 中设置了 f0 最大值和最小值(第 1 层中的“矩”)。

我还有一个“时刻”一词的电话层(在第 2 层),如下所示:

“时刻”一词的电话等级是 M OW M AH NT

=> 我想要 [M AH NT] 的 f0 max 和 f0 min 不包括 [M OW] 这是第一个音节部分。

以下是我到目前为止的脚本。


form Get F0 Min-Max
    sentence Directory ./
    word Base_file_name 
    comment The name of result file
    text textfile F0_list.txt
endform

# Create a header row for the result file:
header$ = "Filename TextGridLabel startTime endTime minTime f0min maxTime f0max'newline$'"
fileappend "'textfile$'" 'header$'

#Read all files in a folder
Create Strings as file list... mp3list 'directory$'/'base_file_name$'*.mp3
Create Strings as file list... gridlist 'directory$'/'base_file_name$'*.TextGrid
n = Get number of strings

for i to n
clearinfo
#We first extract pitch tiers
    select Strings mp3list
    filename$ = Get string... i
    Read from file... 'directory$'/'filename$'
    soundname$ = selected$ ("Sound")
    To Pitch... 0.01 75 600
    output$ = "'soundname$'.Pitch"
    # Write to binary file... 'output$'

# Read grid files and extract the selected intervals in them
    select Strings gridlist
    gridname$ = Get string... i
    Read from file... 'directory$'/'gridname$'
    int=Get number of intervals... 1

# Calculates F0 max, and F0 min (I need interval 10 to be analyzed for the word "moment" so have the 1 10 for the label) 
    select TextGrid 'soundname$'
    label$ = Get label of interval... 1 10 
    if label$ <> ""
        startTime = Get starting point... 1 10
        endTime = Get end point... 1 10 
        select Pitch 'soundname$'
        f0max = Get maximum... startTime endTime Hertz Parabolic
        maxTime = Get time of maximum... startTime endTime Hertz Parabolic
        f0min = Get minimum... startTime endTime Hertz Parabolic
        minTime = Get time of minimum... startTime endTime Hertz Parabolic
        resultline$ = 

"'soundname$''tab$''label$''tab$''syllableTime''tab$''endTime''tab$''minTime''tab$''f0min''tab$''maxTime''tab$''f0max'"
        fileappend "'textfile$'" 'resultline$'
    endif

fileappend "'textfile$'" 'newline$'

endfor

# clean up

select all
Remove

你能帮我解决这个问题吗?太感谢了。

4

1 回答 1

0

您能否添加一个新层来仅分离出您感兴趣的部分?您的数据中还有其他句子吗?

# define your variables
phoneTier = 2
newTier = 3
name$ = "syllable"
regexFirst$ = "M"
regexLast$ = "T"

# use this to add a new tier in each text grid
select TextGrid 'soundname$'
Insert interval tier: newTier, name$

# loop through the phones to find the start time of the syllable
# put this in the for loop that loops through each textgrid
phoneInt = Get number of intervals... phoneTier
for i from 1 to phoneInt-3
    label$ = Get label of interval... i phoneTier
    labelNext$ = Get label of interval... i+3 phoneTier
    if index_regex(label$, regexFirst$) & index_regex(labelNext$, regexLast$)
        start = Get starting point... i phoneTier
        end = Get end point... i+3 phoneTier
        Insert boundary... newTier start
        Insert boundary... newTier end
        syllableInterval = Get low interval at time: newTier, end
        Set interval text... newTier syllableInterval "syllable"
    endif
endfor

然后,测量您刚刚创建的间隔。

于 2018-11-19T18:41:32.347 回答