You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As shown below, I tried to loop through the directory of TextGrid files, extract the first and second tier of each TextGrid and save them as designed file name:
`import tgt
import os
Yes, that's correct. Only TextGrid objects can be saved to a file. I am not sure what you are trying to achieve but you could always create a new TextGrid object with only one Tier and save that.
As shown below, I tried to loop through the directory of TextGrid files, extract the first and second tier of each TextGrid and save them as designed file name:
`import tgt
import os
os.chdir('/Users/ziweizh/Documents/ISU_ALT/2017_Spring/ENGL_515/Final_Project/RSMTool/Feature_Extraction/Prosody/MFA_output')
tg_list = os.listdir('/Users/ziweizh/Documents/ISU_ALT/2017_Spring/ENGL_515/Final_Project/RSMTool/Feature_Extraction/Prosody/MFA_output')[1:-1]
for i in tg_list:
tg = tgt.read_textgrid(i)
word_tier = tg.get_tier_by_name('words')
phone_tier = tg.get_tier_by_name('phones')
os.chdir('/Users/ziweizh/Documents/ISU_ALT/2017_Spring/ENGL_515/Final_Project/RSMTool/Feature_Extraction/Prosody/TG_MFA')
tgt.write_to_file(word_tier,i[:5]+'-'+'word'+'.'+'TextGrid',format = "short")
tgt.write_to_file(phone_tier,i[:5]+'-'+'phone'+'.'+'TextGrid',format = "short")
`
But when I an error message as shown below:
AttributeError: 'Interval' object has no attribute 'tier_type'
Is it because, unlike TextGrid object, an interval tier cannot be written to file?
The text was updated successfully, but these errors were encountered: