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

Error when reading metadata #36

Open
athenasyarifa opened this issue Feb 14, 2024 · 0 comments
Open

Error when reading metadata #36

athenasyarifa opened this issue Feb 14, 2024 · 0 comments
Assignees

Comments

@athenasyarifa
Copy link

Hi Nilo,

It's me again, sorry. I am trying to load my audio files, and segment them using annotations in Raven format (one for each audio file). I made a custom parser for this to return a SegmentAnnotation class object as you instructed in the tutorial. Then, when I have the filepaths for each .wav and the associated .txt file, I tried using the segment_files function to segment the audio files. It raises a ParseError when trying to read the metadata of the .wav file (see below).

File [~/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pykanto/signal/segment.py:467](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/mnt/c/Users/Lenovo/Documents/GitHub/willowtit-project/bioacoustic/~/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pykanto/signal/segment.py:467), in segment_files(datapaths, wav_outdir, json_outdir, resample, parser_func, pbar, **kwargs)
    [461](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pykanto/signal/segment.py?line=460) for wav_dir, metadata_dir in with_pbar(
    [462](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pykanto/signal/segment.py?line=461)     datapaths,
    [463](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pykanto/signal/segment.py?line=462)     desc="Finding and saving audio segments and their metadata",
    [464](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pykanto/signal/segment.py?line=463)     disable=False if pbar else True,
...
--> [192](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pendulum/parsing/iso8601.py?line=191)     return datetime.date(year, month, day)
    [194](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pendulum/parsing/iso8601.py?line=193) if ambiguous_date:
    [195](file:///home/rifsyy/anaconda3/envs/pykanto_env_2/lib/python3.9/site-packages/pendulum/parsing/iso8601.py?line=194)     raise ParserError(f"Invalid date string: {text}")

ValueError: year 0 is out of range

My scripts are the following:

segment_files(
    files_to_segment, 
    json_outdir="/mnt/c/Users/Lenovo/Documents/GitHub/willowtit-project/bioacoustic/data/segmented/willowtit_syllables/JSON",
    wav_outdir="/mnt/c/Users/Lenovo/Documents/GitHub/willowtit-project/bioacoustic/data/segmented/willowtit_syllables/WAV",
    resample=None, 
    parser_func=parse_raven_annot,
    min_duration=3,
    min_freqrange=100
)

I am working with XC audio recordings, and when I checked the metadata of a first wav file using ReadWav(wav_filepaths[0]).all_metadata, it looks like this:

<WAVE({
    'filepath': '/mnt/c/Users/Lenovo/Documents/GitHub/willowtit-project/bioacoustic/willowtit_syllables/Poecile-montanus-130402-cut-1.wav',
    'filesize': '2.35 MiB',
    'pictures': [],
    'streaminfo': <WAVEStreamInfo({
        'audio_format': <WAVEAudioFormat.PCM>,
        'bit_depth': 16,
        'bitrate': '706 Kbps',
        'channels': 1,
        'duration': '00:28',
        'sample_rate': '44.1 KHz',
    })>,
    'tags': <ID3v2Frames({
        'album': ['xeno-canto'],
        'artist': ['Jelmer Poelstra'],
        'comment': [
            <ID3v2Comment({
                'description': '',
                'language': '',
                'text': 'XC130402 © Jelmer Poelstra // Ettingsand, Ã\x96stervÃ¥la area, Uppland (60.257, 17.2172), Sweden // 60m // 07:00h, 2013-03-31 // song //  /  / bird-seen:no /  / playback-used:no // also:  Coal Tit, Great Spotted Woodpecker, Eurasian Bullfinch, European Crested Tit, Great Tit',
            })>,
        ],
        'genre': ['Paridae'],
        'title': ['Willow Tit (Poecile montanus)'],
        'usertext': [
...
            })>,
        ],
    })>,
})>

How can I fix this? Should I edit the metadata according to how your script parse it? I would be really grateful for your suggestion when you have time!

Best,
Rifa

@nilomr nilomr self-assigned this Jul 2, 2024
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