Open nilomr opened 2 hours ago
Hi Advay,
Could you please provide a reproducible example, including traceback? In the meantime, the docs might help: setting up a project
@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
data_dir = "wav_files" # Directory containing audio (.wav) and JSON files output_dir = "wav_files/output" # Directory for output
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 )
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!
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:
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
Continues from https://github.com/nilomr/pykanto/issues/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