我试图用静音替换某些声音选择,但在我进入基本部分之前,“从间隔获取标签”命令在我能够检查是否获得正确的输出之前失败。
我以为我玩的玩具音频有问题,所以我换了另一个,但奇怪的是,每次我总是卡在序列中的第三个间隔。此处提供屏幕截图:
我现在使用的代码非常简单,如下所示:我如何处理标记为“听起来”的间隔可能存在问题,但它应该与我在这里遇到的错误无关。
-------------------------------------------------- --------------------------
soundname$ = chooseReadFile$: "Open a sound file"
sound = Read from file: soundname$
gridname$ = chooseReadFile$: "Select the corresponding TextGrid file."
grid = Read from file: gridname$
tier = 1
soundEnd = Get total duration
numOfIntervals = Get number of intervals: tier
writeInfoLine: "Number of Intervals:", numOfIntervals
appendInfoLine: "**** Starting to Replace Selected Sounds... ****"
for interval from 1 to numOfIntervals
appendInfoLine: "Interval#", interval
label$ = Get label of interval: tier, interval
appendInfoLine: "Interval#", interval, ": ", label$
if label$ == "sounding"
startTime = Get starting point: tier, interval
endTime = Get end point: tier, interval
newSilence = Create Sound from formula: "new_silence", 1, startTime, endTime, 44100, ~ 0
before = Extract part: 0, startTime, "rectangular", 1, "no"
after = Extract part: endTime, soundEnd, "rectangular", 1, "no"
selectObject: before, newSilence, after
new = Concatenate
Write to WAV file... "new".wav
removeObject: before, newSilence, after
endif
endfor
appendInfoLine: "Finish!"
-------------------------------------------------- --------------------------
我怀疑是因为我的编辑,TextGrid 中发生了一些变化——但是,由于我只用相同长度的静音代替了声音,所以之后不应该对声音或 TextGrids 产生影响。但是,由于我从来没有机会输出一些可播放的音频结果,所以我上面推断的所有内容都无法得到确凿的事实证实。
非常感谢大家的关心和提前帮助!