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

Issue with initializing KantoData #41

Open
nilomr opened this issue Nov 20, 2024 · 3 comments
Open

Issue with initializing KantoData #41

nilomr opened this issue Nov 20, 2024 · 3 comments
Assignees

Comments

@nilomr
Copy link
Owner

nilomr commented Nov 20, 2024

Continues from #40

@advaymishra2003 wrote:

... However, I am running into some other problems. I am setting up pykanto to process audio data but ran into an issue with initializing KantoData. Here’s the problem and what I tried:

Issue
When trying to initialize KantoData, I got this error:
AttributeError: 'Parameters' object has no attribute 'DATASET_ID'

It seems that KantoData expects DATASET_ID within the DIRS parameter. However, ProjDirs wasn’t accessible in the import, so I couldn’t set up DIRS properly. I attempted to workoaround this problem and I created a custom CustomDirs class to manually define the directory structure and provide DATASET_ID:

class CustomDirs:
def init(self, data_dir, output_dir):
self.DATA_DIR = data_dir
self.OUTPUT_DIR = output_dir
self.DATASET_ID = "your_dataset_id"

Then I used it as follows:

custom_dirs = CustomDirs(data_dir, output_dir)
dataset = KantoData(DIRS=custom_dirs, parameters=params)

Unfortunately, this workaround didn’t resolve the issue and led to the same error.

Question
Is there an updated way to set up DIRS with the current version of pykanto, or is there a recommended approach for defining the necessary attributes for KantoData initialization?

Thanks for your help!

Best,
Advay Mishra

@nilomr
Copy link
Owner Author

nilomr commented Nov 20, 2024

Hi Advay,

Could you please provide a reproducible example, including traceback? In the meantime, the docs might help: setting up a project

@nilomr
Copy link
Owner Author

nilomr commented Nov 20, 2024

@advaymishra2003 wrote:

Hi @nilomr ,

Thank you for getting back to me so quickly! Here's a reproducible example of the issue I encountered, along with the traceback.

import pykanto
from pykanto.dataset import KantoData
from pykanto.parameters import Parameters

Step 1: Define paths for data and output

data_dir = "wav_files" # Directory containing audio (.wav) and JSON files
output_dir = "wav_files/output" # Directory for output

Step 2: Initialize Parameters

params = Parameters(
data_dir=data_dir,
output_dir=output_dir,
lowcut=0,
highcut=7000,
window_size=0.03,
overlap=0.5,
threshold=0.1,
song_level=False
)

Step 3: Initialize the KantoData object

dataset = KantoData(DIRS=params, parameters=params) # Using params for DIRS

Traceback
Here’s the traceback from the execution:
AttributeError: 'Parameters' object has no attribute 'DATASET_ID'
Traceback (most recent call last):
File "/opt/anaconda3/envs/pykanto_env_jupyter/lib/python3.9/site-packages/pykanto/dataset.py", line 110, in init
self.DATASET_ID = DIRS.DATASET_ID
AttributeError: 'Parameters' object has no attribute 'DATASET_ID'

Since I couldn't import ProjDirs (as it wasn’t accessible), I tried a workaround by defining a custom CustomDirs class with the required attributes (DATASET_ID, DATA_DIR, OUTPUT_DIR) and passing it as the DIRS argument. Unfortunately, this also resulted in the same error.

Let me know if you need any additional details or files to reproduce the issue.

Thanks again for your support!

@nilomr
Copy link
Owner Author

nilomr commented Nov 20, 2024

Hi,

Please refer to the docs at https://nilomr.github.io/pykanto for examples of projects created using pykanto. Here's one showing you how to segment vocalisations into units.

You can download these examples as Jupyter notebooks as well:
image

You can use your IDE or the pykanto docs to consult the documentation for each function. E.g., to see valid arguments and variable types that you can pass to the KantoData class, see pykanto.dataset.KantoData. Based on your example, it seems that you haven't created a ProjDirs object, which is the first argument that KantoData expects. This is explained here: set-up-project-directories.

Lastly, am not sure what you mean by this: "I couldn't import ProjDirs (as it wasn’t accessible)". Tests for pykanto are running OK; from pykanto.utils.paths import ProjDirs works on my side.

Hope that helps!
Nilo

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

1 participant