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

Problem with shifting #7

Open
georgid opened this issue Nov 4, 2016 · 5 comments
Open

Problem with shifting #7

georgid opened this issue Nov 4, 2016 · 5 comments

Comments

@georgid
Copy link

georgid commented Nov 4, 2016

If I run this script with last line commented I dont get an error.
The error seems to be raised on tgt.write_to_file. which is confusing. I guess it should be raised already on tier.add_interval()

@mwlodarczak
Copy link
Collaborator

Could you please provide more information about this bug? What code triggered it? The traceback you have provided mentions write_to_file, not shift.

@mwlodarczak
Copy link
Collaborator

This error is not caused directly by add_tier but by the fact that you are both modifying (in place) start and end times and adding the modified interval to the same tier.

Arguably, that is not something that you should be doing but the error message is indeed confusing. The problem is two-fold: (1) modifying start and end times does not actually move the interval up or down the tier, which (2) confuses add_interval which uses bisect.bisect_left.

@hbuschme hbuschme changed the title Problem iwth shifting Problem with shifting Nov 7, 2016
@hbuschme
Copy link
Owner

hbuschme commented Nov 7, 2016

We are currently working on an improved representation of Annotations that prevents these kind of problems.

For the moment I would recommend to create a new Tier and to add Annotation 0-50 (in your script) as well as the shifted Annotations to this new Tier. Then remove the old Tier and add the new Tier to the TextGrid object.

@georgid
Copy link
Author

georgid commented Nov 12, 2016

Thank you guys for the feedback.
The use case I had in mind is:
I am doing annotations on word boundaries on a given tier. I annotate a song, in which the chorus repeats. When doing chorus for the second time Instead of retyping the words, I would like to copy the words and their respective timestamps form chorus 1; everything being same, just shifted by an time (chorus2.beginTs-chorus1.endTs)
Do you know how can I do this maybe with another Praat script?

@hbuschme the suggestion is fine, but somewhat cumbersome, if I have to do it each repetition in a highly repetitive song, maybe I would type the words in the end :(

@mwlodarczak
Copy link
Collaborator

I see. I think what you are trying to achieve should be perfectly
possible with tgt as long as you do not modify the existing annotation
(which, as far as I can see, is not what you want since you want the
original chorus to remain in its original place). In other words,
instead of saying:

for anno in a[51:-1]:
    anno.end_time += shiftTime
    anno.start_time +=  shiftTime
    tier.add_interval(anno)

create a new shifted annotation like this:

for anno in a[51:-1]:
    anno_shifted = tgt.Interval(anno.start_time + shiftTime,
                                anno.end_time + shiftTime,
                                anno.text)
    tier.add_interval(anno_shifted)

Hope this helps!
Marcin

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

3 participants