我有以下問題:我想低通濾波器240 WAV文件。該腳本僅在創建低通濾波聲音並顯示在對象列表(「..._ band」)中之前運行。但是,Praat不會將它們導出爲WAV文件。選擇輸出文件夾後,我會收到警告消息「Command」獲取字符串數量「不適用於當前選擇」。如何將操縱的WAV文件保存在對象列表中?
總之,我的問題是如何將WAV聲音保存到對象列表中,並使用它們的新文件名?另見Screenshot。
腳本見下文。
非常感謝您的幫助!
問候,
#determine praat version
ver1$ = left$(praatVersion$, (rindex(praatVersion$, ".")-1));
ver1 = 'ver1$'
if ver1 < 5.2
exit Please download a more recent version of Praat
endif
if ver1 == 5.2
ver2$ = right$(praatVersion$, length(praatVersion$) - (rindex(praatVersion$, ".")));
ver2 = 'ver2$'
if ver2 < 4
exit Please download a more recent version of Praat (minor)
endif
endif
beginPause ("Low-Pass Filter Instructions")
comment ("1. Select a folder containing the wave files to be low-pass filtered")
comment ("2. Wave files will be low-pass filtered (0 - 400 Hz)")
comment ("3. Select an output folder for the low-pass filtered wave files to be saved to")
comment ("Click 'Next' to begin")
clicked = endPause("Next", 1);
#wavefile folder path
sourceDir$ = chooseDirectory$ ("Select folder containing wave files")
if sourceDir$ == ""
exit Script exited. You did not select a folder.
else
sourceDir$ = sourceDir$ + "/";
endif
Create Strings as file list... list 'sourceDir$'/*.wav
numberOfFiles = Get number of strings
levels$ = ""
for ifile to numberOfFiles
select Strings list
currentList = selected ("Strings")
filename$ = Get string... ifile
Read from file... 'sourceDir$'/'filename$'
currentSound = selected ("Sound")
filterFreqRange = Filter (pass Hann band)... 0 400 20
select currentSound
Remove
endfor
select currentList
Remove
#output folder path - where the wave files get saved
outputDir$ = chooseDirectory$ ("Select folder to save wave files")
if outputDir$ == ""
exit Script exited. You did not select a folder.
else
outputDir$ = outputDir$ + "/";
endif
numberOfFiles = Get number of strings
for ifile to numberOfFiles
select Strings list
currentList = selected ("Strings")
filename$ = Get string... ifile
currentSound = selected ("Sound")
endif
Save as WAV file... 'outputDir$'/'filename$'
select currentSound
Remove
endfor
#clean up
select currentList
Remove
#clear the info window
clearinfo
#print success message
printline Successfully low-pass filtered 'numberOfFiles' wave files.
謝謝你的回答。不幸的是,這不符合你的建議。 – username
我已經正確地確定了問題的根源,但不是其範圍。事實證明,你的腳本在選擇時遇到了很多問題。我用腳本的工作版本更新了我的答案,並提供了一些指向其他資源的鏈接。 – jja
非常感謝您的幫助,jja !! 現在它工作,我改變了唯一的是以下,因爲它保存了沒有文件類型結尾的聲音: '另存爲WAV文件:output_dir $ +「/」+選中$(「Sound」)+「.wav 「' – username