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

Exporting units as .wav and .json? #37

Open
ArKornreich opened this issue Jul 1, 2024 · 2 comments
Open

Exporting units as .wav and .json? #37

ArKornreich opened this issue Jul 1, 2024 · 2 comments
Assignees

Comments

@ArKornreich
Copy link

Hi Nilo!

Thank you again so much for your help earlier this year, and sorry to keep bothering you with questions!

Is there a way to take the units of songs and, before they are projected in the interactive app, save them much the way the segmenting process generates .wav files and .json files for individual songs in longer recordings? This functionality probably exists, but embarassingly I'm having a bit of trouble figuring out how to do this.

Thank you!

@nilomr
Copy link
Owner

nilomr commented Jul 2, 2024

Hi Ar

Happy to help!

Is there a way to take the units of songs and, before they are projected in the interactive app, save them much the way the segmenting process generates .wav files and .json files for individual songs in longer recordings? This functionality probably exists, but embarassingly I'm having a bit of trouble figuring out how to do this.

Yes, you can easily save individual files for each 'unit' by loading the file that contains it and using the existing unit onset and offset times to extract and save them one by one.

https://gist.github.com/nilomr/dc153c7c6b1b399a837355548d2ffdd7

There you can see how to get onset and offsets as well as labels if they exist, eg

key = "any_song_key"
onsets = dataset.data.loc[key, "onsets"]
offsets = dataset.data.loc[key, "offsets"]
labels = dataset.data.loc[key, "song_seq"]

Once you have that you can open the wav for that song and segment it using your favourite method. You could use the soundfile module as in this example:

def save_segments(

Hope that helps!
Nilo

@nilomr nilomr self-assigned this Jul 2, 2024
@ArKornreich
Copy link
Author

Hi Nilo!

I'm so sorry for my delay in getting back to you! I'm going to try to test this sometime this week and get back to you with any issues. I haven't forgot about this! Deepest apologies!

Best,

Ar K

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

No branches or pull requests

2 participants