Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tgt.write_to_file issue #8

Closed
ziweizh opened this issue Apr 21, 2017 · 1 comment
Closed

tgt.write_to_file issue #8

ziweizh opened this issue Apr 21, 2017 · 1 comment

Comments

@ziweizh
Copy link

ziweizh commented Apr 21, 2017

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?

@mwlodarczak
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants