如何 运行 在 Praat 脚本中针对声音的特定部分进行语音报告?

How to run Voice Report in a Praat script for a specific part of the sound?

我是 Praat 脚本的新手,我正在尝试提取语音报告,但是在声音文件而不是整个文件中的特定 start/end 时间。从手册中,给出了这个例子:

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)

这 运行 是整个文件的语音报告。

从其他一些有用的示例中,我能够将以下脚本放在一起,该脚本创建了具有 "silent" 和 "sounding" 层的 TextGrid。我想 运行 每个探测行的语音报告(beginsound 和 endsound 是标记)。

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

据我所知,Voice Report 可以 运行 在 TextGrid 选择或 Sound + Pitch + PointProcess 对象的选择上。我不确定如何将 Voice Report 命令添加到我的 for 循环中。非常感谢任何 help/direction。谢谢

简答

您提到的 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

旁白

尽管忽略这一点,但顺便说一句,您还计算了一些您并不真正需要的变量。在您的脚本中,soundsoundid 具有相同的值,textgridtextgridid 也是如此。还有这个:

To TextGrid (silences)... 60 0.3 0.1 silent sounding
textgridid = selected("TextGrid")

可以转成这个

textgridid = To TextGrid (silences): 60, 0.3, 0.1, "silent", "sounding"

您还在混合使用 "shorthand" 和新的语法样式,这肯定会造成混淆。喜欢新款式。