我是Praat脚本的新手,我正在尝试提取语音报告,但是对于声音文件中的特定开始/结束时间而不是整个文件。从手册中,给出了这个例子:
voiceReport$ = Voice report: 0, 0, 75, 500, 1.3, 1.6, 0.03, 0.45
jitter = extractNumber (voiceReport$, "Jitter (local): ")
shimmer = extractNumber (voiceReport$, "Shimmer (local): ")
writeInfoLine: "Jitter = ", percent$ (jitter, 3), ", shimmer = ", percent$ (shimmer, 3)
这会运行整个文件的语音报告。
从其他一些有用的例子中,我能够将以下脚本放在一起,创建一个带有“静音”和“发声”层的TextGrid。我想在每个探测行上运行语音报告(beginound和endound是标记)。
form analysis
sentence inputFile
endform
sound = Read from file: inputFile$
selectObject: sound
soundname$ = selected$("Sound")
soundid = selected("Sound")
To TextGrid (silences)... 60 0.3 0.1 silent sounding
textgridid = selected("TextGrid")
select 'textgridid'
silencetierid = Extract tier... 1
silencetableid = Down to TableOfReal... sounding
nsounding = Get number of rows
npauses = 'nsounding'
speakingtot = 0
for ipause from 1 to npauses
beginsound = Get value... 'ipause' 1
endsound = Get value... 'ipause' 2
speakingdur = 'endsound' - 'beginsound'
speakingtot = 'speakingdur' + 'speakingtot'
printline sounding 'beginsound' 'endsound'
comment How to run Voice Report between beginsound and endsound?
endfor
根据我的理解,语音报告可以在TextGrid选择上运行,也可以在选择的Sound + Pitch + PointProcess对象上运行。我不知道如何将语音报告命令添加到我的for循环中。非常感谢任何帮助/方向。感谢。
答案 0 :(得分:1)
您提到的Voice report...
命令中的前两个参数是用于报告的块的开始和结束时间。如果你对这两个值使用0
,那么Praat将获取整个声音,但你可以指定你想要的任何值。
如果所需对象(Sound,Pitch和PointProcess对象)计算一次,您的脚本将会更快,因为您可以指定时间范围。如果您不是从编辑器中运行它,而是直接使用对象,它也会是最快的。
您也不需要将TextGrid转换为TableOfReal:您可以直接查询声音间隔的开始和结束时间,方法是检查标签的内容以确保它是一个你想要的间隔。
# Initial variables, just to make the parameters clearer
pitch_min = 60
pitch_max = 600
time_step = 0.3
silence_threshold = -25
min_pause = 0.1
min_voiced = 0.1
tier = 1
# Detect silences
sound = selected("Sound")
textgrid = To TextGrid (silences): pitch_min, time_step,
... silence_threshold, min_pause, min_voiced, "silent", "sounding"
# The TextGrid is automatically selected
total_intervals = Get number of intervals: tier
# Make the remaining objects
selectObject: sound
pitch = To Pitch: 0, pitch_min, pitch_max
selectObject: sound
pulses = To PointProcess (periodic, cc): pitch_min, pitch_max
# Find beginning and end of sounding intervals
for i to total_intervals
selectObject: textgrid
label$ = Get label of interval: tier, i
if label$ == "sounding"
start = Get start point: tier, i
end = Get end point: tier, i
selectObject: sound, pitch, pulses
report$ = Voice report: start, end,
... pitch_min, pitch_max, 1.3, 1.6, 0.03, 0.45
# Do whatever you want with the report
endif
endfor
# Clean up
removeObject: textgrid, pitch, pulses
随意忽略这一点,但是除此之外,您还要计算一些您并不真正需要的变量。在您的脚本中,sound
和soundid
保持相同的值,textgrid
和textgridid
也是如此。这个:
To TextGrid (silences)... 60 0.3 0.1 silent sounding
textgridid = selected("TextGrid")
可以转为此
textgridid = To TextGrid (silences): 60, 0.3, 0.1, "silent", "sounding"
你也在混合"简写"和新的语法样式,这肯定会混淆事情。喜欢新风格。