8000 creating wandb.Audio from pathlib.Path raises error · Issue #4387 · wandb/wandb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

creating wandb.Audio from pathlib.Path raises error #4387

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

Closed
sammlapp opened this issue Oct 19, 2022 · 2 comments · Fixed by #9692
Closed

creating wandb.Audio from pathlib.Path raises error #4387

sammlapp opened this issue Oct 19, 2022 · 2 comments · Fixed by #9692
Labels
a:sdk Area: sdk related issues c:sdk:media Component: Relating to media

Comments

@sammlapp
Copy link

Describe the bug

Trying to create a wandb.Audio object by passing a pathlib.Path instead of a string raises "ValueError: Argument "sample_rate" is required when instantiating wandb.Audio with raw data."

Because the class accepts either a path or raw audio data, I would expect it to also handle a pathlib.Path object as if it were a string.

from pathlib import path
import wandb
wandb.Audio(Path('file.wav'))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
----> 1 wandb.Audio(Path('audio.wav'))

~/miniconda3/envs/opso_dev/lib/python3.9/site-packages/wandb/data_types.py in __init__(self, data_or_path, sample_rate, caption)
   1055         else:
   1056             if sample_rate is None:
-> 1057                 raise ValueError(
   1058                     'Argument "sample_rate" is required when instantiating wandb.Audio with raw data.'
   1059                 )

ValueError: Argument "sample_rate" is required when instantiating wandb.Audio with raw data.

Additional Files

No response

Environment

WandB version: '0.13.4'

OS: Mac OS 12.6

Python version: Python 3.9.13

Versions of relevant libraries:

Additional Context

No response

@sammlapp sammlapp added the a:sdk Area: sdk related issues label Oct 19, 2022
@ramit-wandb
Copy link
Contributor

Hi @sammlapp,

As the error message suggests, sample_rate is a required argument when reading from a file. Please pass in the sample rate to your wandb.Audio object. You can read more about the arguments on our docs here : https://docs.wandb.ai/ref/python/data-types/audio

Thanks,
Ramit

@kptkin
Copy link
Collaborator
kptkin commented Oct 20, 2022

@sammlapp Thanks for reporting this issue. You are right we are currently don't handle pathlib.Path (see the documentation linked by @ramit-wandb) in the code. In the meantime you could convert the Path instance to a string and it should work for the current version. We are going to add support for Path in on of the future releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:sdk Area: sdk related issues c:sdk:media Component: Relating to media
Projects
None yet
3 participants
0