| # dataset.py | |
| from datasets import DatasetBuilder, DatasetInfo, SplitGenerator, Features, Value, Audio | |
| import os | |
| import pandas as pd | |
| class MarathiTTSDataset(DatasetBuilder): | |
| def _info(self): | |
| return DatasetInfo( | |
| description="Marathi Text-to-Speech dataset.", | |
| features=Features({ | |
| 'audio': Audio(sampling_rate=22050), # Adjust if your audio has a different sampling rate | |
| 'text': Value('string'), | |
| }), | |
| supervised_keys=None, | |
| ) | |
| def _split_generators(self, dl_manager): | |
| data_dir = os.path.abspath(".") | |
| return [ | |
| SplitGenerator( | |
| name="train", | |
| gen_kwargs={ | |
| "filepath": os.path.join(data_dir, "train.csv"), | |
| }, | |
| ) | |
| ] | |
| def _generate_examples(self, filepath): | |
| df = pd.read_csv(filepath) | |
| for idx, row in df.iterrows(): | |
| yield idx, { | |
| 'audio': row['audio'], | |
| 'text': row['text'], | |
| } | |