2017-01-23 76 views
0

我有一個來自for循環的對象列表,我想將它們附加到列表中,以便我可以選擇並連接它們。我的想法是,代碼將發揮作用或多或少是這樣的:選擇praat中的對象列表

for stringNumber from 0 to numberOfStrings 
    do string stuff... 


    tgID = Create TextGrid: tmin, tmax, tier_name$, phone$ 
    Set interval text: 1, 1, phone$ 
    # THIS IS WHERE I NEED HELP 
    tgList = append: tgID + ", " 

endfor 

selectObject: tgList 
do ("Concatenate") 

回答

3

你可以試試這個:

for stringNumber from 0 to numberOfStrings 
    # do string stuff... 

    tgID = Create TextGrid: tmin, tmax, tier_name$, phone$ 
    Set interval text: 1, 1, phone$ 

    tgList[stringNumber + 1] = tgID 
endfor 

selectObject() 

for i from 1 to numberOfStrings + 1 
    plusObject: tgList[i] 
endfor 

Concatenate 

selectObject()將取消一切,然後plusObject將當前對象的選擇。我不確定循環索引在選擇循環中是否正確,因爲你從0開始循環,而且我不能嘗試你的代碼。

+0

這是plusObject和selectObject的關鍵。謝謝! – badner

+0

對於'selectObject()'+1。到現在爲止,我一直在做'nocheck selectObject:undefined',這更加神祕...而且時間更長。 – jja

0

這可能是矯枉過正在這種特殊情況下,但你也可以使用selection插件,在CPrAN可用的,這是爲了管理對象選擇(全面披露:我寫的):

include ../../plugin_selection/procedures/tables.proc 

@createEmptySelectionTable() 
selection = createEmptySelectionTable.table 

for stringNumber from 0 to numberOfStrings 
    Create TextGrid: tmin, tmax, tier_name$, phone$ 
    Set interval text: 1, 1, phone$ 
    @addToSelectionTable: selection 
endfor 

@restoreSavedSelection: selection 
removeObject: selection 
Concatenate 

對於這個工作,但是,你需要你的腳本在一個插件的子目錄中(所以在Linux/Mac中的~/.praat-dir/plugin_foo/scripts/here.praat)。

希望在未來會有解決方法。然後再次,大多數Praat腳本確實應該在插件中,即使它們是項目特定的,所以... </rant>