-
Notifications
You must be signed in to change notification settings - Fork 16
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
BUG: error when running vak prep
with "textgrid" annot_format
#511
Comments
Thank you @yangzheng-121 for opening this issue and providing helpful detail. I'm pasting the image here just to make it easier to reference, hope that's okay Can you explain where the label [edit] I see above you wrote
but I just want to make sure -- you label all silent periods (between syllables and before and after songs) with Here's three possible solutions:
[PREP]
labelset = ['a', 'b', 'c', 'd', 'e', ''] Notice the last label is the empty string. >>>help(vak.converters.labelset_to_set) you can read the docstring that explains how the TOML values get converted to the thing that
You could do this with
For both 2. and 3., I would make back-up copies of your data before trying either, so you don't damage your hand-annotated files, which I'm sure took some time to create. I can write a small example script of how you would rename or remove the |
🤔 It would actually be much easier to do 2. and 3. above with the current version of With the newest version, to remove all the silent period labels, you'd do something like: import pathlib
import crowsetta
data_dir = pathlib.Path('C:\Users\LabUser\Desktop\DataFolder\song_analysis\tweetynet_bl097\tutee_bl097_tntrain')
textgrid_paths = sorted(data_dir.glob('*.TextGrid')) # I assume the extension is .TextGrid
scribe = crowsetta.Transcriber('textgrid')
for textgrid_path in textgrid_paths:
tg = scribe.from_file(texgrid_path)
intv_tier = tg.textgrid[0]
new_intv_tier = crowsetta._vendor.textgrid.IntervalTier()
for interval in intv_tier:
if interval.mark != '': # skip any interval labeled with `''`
new_intv_tier.addInterval(interval)
tg.textgrid[0] = new_intv_tier
with textgrid_path.open('w') as fp:
tg.textgrid.write(fp) This is totally untested but plus or minus a couple minor bugs it should work. |
I think by default Praat will give all the intervals that I didn't label a '', including the periods between syllables, and periods before and after the song bouts. I didn't give it a '' label, so I also couldn't delete it in Praat. I also have a question after reading your answer. Am I supposed to label only syllables? Cause I thought that tweetynet also need cage noise or calls when training, so I actually also label noise and calls. If that's not necessary, then I will delete it in my annotation. I tested the script you provided, and I got error like this:
|
Thank you, this is helpful to know.
In the paper we did not label noise / calls. We have also not tested how much this matters. In theory the network should learn to classify anything you leave unlabeled as "background" and so far we have found this to be the case. If you are concerned about this because you have data with a lot of calls then it may be worth testing by keeping the files where you have annotated those sounds by hand, and seeing whether models trained with just "syllable classes + background" classify those sounds as background.
Before running this, did you install
|
@yangzheng-121 did you try solution 1. above?
[PREP]
labelset = ['a', 'b', 'c', 'd', 'e', ''] Let me know if it's not clear what I'm suggesting here |
vak prep
with "textgrid" annot_format
A few feedback.
I then turned to solution 2&3, but I think I probably didn't understand it correctly. I downloaded the code from this page: https://github.com/vocalpy/crowsetta, and then I cd into the directory of the downloaded code. I activated my conda environment for tweetynet, and then I did pip install crowsetta. The command window gave me some feedback like "requirement already satisfied"
|
Ah right, I'm sorry, I forgot that those post-processing steps do require the unlabeled "background" segments to be present. You should be able to run majority_vote = true
min_segment_dur = 0.01 (The default for But my guess is that without the clean-up steps, the predictions will be noisier than you want.
Ah, my fault for not explaining more clearly. Notice the period I wrote: pip install . where the period pip install .\crowsetta\ or you could write the absolute path: pip install C:\Users\LabUser\Desktop\repos\crowsetta (replace what I wrote with the actual path, obviously) |
Asked on twitter to see if other people using Praat have run into this issue: I know there are .TextGrid datasets out there without these "empty string labels". Not sure what your method is now--I guess you are finding all the segments "by eye"?--but one option would be to:
You'd want to write a script to do this. |
Hi @yangzheng-121 thank you for following up -- I had meant to get back to you. We would really like to make sure
Agreed this is the default, at least as far as I can tell by loading public datasets using
Not quite. I expect that it will work, but you will have noisy segmentation because it does not do the post-processing that cleans up.
If I were you, this is what I would do. I'll post it here too so we can refer people to this issue until we figure out a longer term solution for working with .TextGrid annotations. (It's definitely not convenient to need to remove labels from your annotation all the time) |
Hi David, Sita here. Thanks again for helping us out! I found out that praat can convert textgrids to csv so we can use the simple-seq format. I wrote a praatscript to convert multiple ones. now the column order is onset tier label offset, but I think this can be edited with the 'from-file' argument in simple-seq if I'm correct? Maybe you could implement it in tweetynet permanently with parselmouth? https://parselmouth.readthedocs.io/en/stable/ |
Hi @sthaar
Great, this is good to know. When you convert to .csv, do you still get the segments with labels that are empty strings, as @yangzheng-121 described above? I think this is the main issue we want to fix here. It seems to be the case that Praat requires all possible Intervals in a Tier to have a string label, and this is what results in the unlabeled Intervals getting assigned a label of "empty string". As @drfeinberg pointed out on twitter
You can definitely try training a model using data with the silent gaps labeled. You should be able to run predict anyway, if you just remove the options from the config file that do the post-processing:
You are right that the newest version of You will want to write a script to convert your .csv files to the simple-seq format as described here: I am more than happy to do this for you and will probably add a "how-to" to the
Thank you for sharing this, I see the script here I think? But again you want to remove any labels on silent gaps, so that you can apply the clean up steps when you predict new labels.
Thank you, I am aware of I hope this reply doesn't come off as grumpy or pedantic, just trying to make sure I'm clear Let's definitely meet soon and talk some off this out because I think we are nearing the limits of communication via GitHub issue 😄 and I do want to help you |
Hi sorry for the late reply, in meetings all day,
sorry I wasn't clear about this, it's without labels for empty segments! You can choose to exclude empty intervals in praat. In my praatscript it's line 16 The output of the script is now a file with .wav.csv extension, with column names 'onset_s', 'labels', and 'offset_s' with a gap between the two xs labels So if I'm correct this is already the simple-seq format? At least,
No worries of course! again happy you're taking the effort. I'm aware of the cowsetta version transition so I'll just wait for the new version :) let me know if we can help out with reading/testing! And I'll email about a zoom meeting indeed! |
Hi, David, I was trying to use vak with textgrid files, I changed these 2 lines in the gy6or6_train.toml file:
audio_format = "wav"
annot_format = "textgrid"
I ran it with the command: vak prep C:\Users\LabUser\Desktop\DataFolder\song_analysis\gy6or6_train.toml
This is the error I got:
As far as I understand, this means I have an empty lable which cannot be recognized, but in the annotation there will always be empty part(which is the silent interval between song or noise). I can upload one example of my annotation. It's a picture not the original file cause the file type is not supported.
Doc1.docx
The text was updated successfully, but these errors were encountered: