2016-01-13 108 views
0

我是新來praat,所以也許這是一個簡單的問題。我嘗試在praat中創建一個腳本,該腳本將通過for循環遍歷對象列表中的某些對象,並刪除silenct間隔。我已經創建了這個腳本,我將把它放在for循環中。Praat腳本刪除沉默,不能選擇和刪除對象

selectObject: i 
inten=To Intensity... 100 0 "no" 
txt=To TextGrid (silences)... -35 0.1 0.05 'silent' 'sounding' 
selectObject: i 
plusObject: txt 
Extract intervals where: 1, "no", "contains", "sounding" 
myobj=Concatenate 
Copy: string$(i) 
selectObject: inten 
plusObject: txt 
plusObject: myobj 
Remove 

雖然我得到我想要的我的問題是在該行

Extract intervals where: 1, "no", "contains", "sounding" 

在這一行包含聲音部分提取和選擇。然後立即使用連接來創建所需的文件並選擇它。但是,因爲這條線產生更多的一個變量,我不能保存它。因此,稍後我沒有從我的對象目錄中刪除它的引用。雖然我仍然可以運行它,因爲我的目錄會被淹沒,我不認爲這是優雅的。有什麼建議麼?

回答

1

這聽起來很明顯,但您可以通過將多個提取的間隔保存到索引變量中,然後在需要刪除它們時重新選擇它們來保存多個提取間隔的ID號。

下面你會發現你的腳本的編輯和評論版本。我改變了一些變量名,以便更容易遵循。

sound = selected() 
intensity = To Intensity: 100, 0, "no" 
textgrid = To TextGrid (silences): -35, 0.1, 0.05, silent, sounding 

# Select multiple objects at once 
selectObject: sound, textgrid 

Extract intervals where: 1, "no", "contains", "sounding" 

# Save the ID numbers of the currently selected intervals 
total_parts = numberOfSelected() 
for i to total_parts 
    part[i] = selected(i) 
endfor 

# No need to make a copy just to rename 
sounding = Concatenate 
Rename: string$(sound) 

# Select all the objects you want to remove 
selectObject: intensity, textgrid 
# Including the extracted intervals 
for i to total_parts 
    plusObject: part[i] 
endfor 
# And remove them 
Remove 

# If you knew beforehand what objects to select, 
# you could also use removeObject() 

# Select your concatenated sound 
selectObject: sounding 

順便說一句,在selection插件可通過CPrAN寫,使其更易於管理普瑞特對象選擇了這樣的情況下。上面插入的兩個循環可能已被@saveSelection()@restoreSelection()(完全披露:我寫了該插件)的調用所取代。

+0

就像我說的我是新來的praat,所以根本不明顯。非常感謝! – Dimitris