2

我是 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。我想在每个发声行上运行语音报告(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

据我了解,语音报告可以在 TextGrid 选择或 Sound + Pitch + PointProcess 对象的选择上运行。我不确定如何在此处将 Voice Report 命令添加到我的 for 循环中。非常感谢任何帮助/指导。谢谢。

4

1 回答 1

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

旁白

随意忽略这一点,但顺便说一句,您还计算了许多您并不真正需要的变量。在您的脚本中,soundandsoundid保持相同的值,对于 and 也是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"

您还将“速记”和新的语法样式混合在一起,这肯定会使事情变得混乱。更喜欢新风格。

于 2016-03-26T17:17:57.077 回答