Skip to content

Commit

Permalink
Merge pull request #77 from DIDONEproject/tutorials
Browse files Browse the repository at this point in the history
Tutorials
  • Loading branch information
CarlosVaquero authored Oct 11, 2024
2 parents 30ea4c7 + c82a5f8 commit 0df74ca
Show file tree
Hide file tree
Showing 7 changed files with 982 additions and 1,092 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ https://github.com/DIDONEproject/music_symbolic_features

## Changelog

#### v1.2.4
* Fix on lyrics module. Implemeted error output file for error registration.

#### v1.2.3
* Minifix on lyrics module

Expand Down
843 changes: 0 additions & 843 deletions docs/source/Tutorial poprock.ipynb

This file was deleted.

344 changes: 97 additions & 247 deletions docs/source/Tutorial.ipynb

Large diffs are not rendered by default.

863 changes: 863 additions & 0 deletions docs/source/Tutorial_poprock.ipynb

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions musif/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,22 @@ def extract(self) -> DataFrame:

return score_df

def _check_for_error_file(self):
# Check for error file
try:
df = pd.read_csv(f'{self._cfg.output_dir}/error_files.csv', low_memory=False)
df['ErrorFiles'] = df['ErrorFiles'].astype(str)
df['ErrorFiles'] = df['ErrorFiles'].str.rsplit('/', 1).str[-1]
errored_files = list(df['ErrorFiles'])
print(errored_files)
print("CSV loaded successfully.")
except Exception:
# Handle the case where the file is empty
print("There is no error_files.csv, it will be created and loaded error files are included manually in it.")
import os
if not os.path.exists(f'{self._cfg.output_dir}'):
os.makedirs(f'{self._cfg.output_dir}')

def _process_corpus(
self, filenames: List[PurePath]
) -> Tuple[List[dict], List[dict]]:
Expand All @@ -322,6 +338,7 @@ def process_corpus_par(idx, filename):
else:
score_features = self._process_score(idx, filename)
except Exception as e:
self._check_for_error_file()
print(f"Error found on {filename}. Saving the filename and error print to {str(self._cfg.output_dir)}/error_files.csv for latter tracking")
error_files.append(filename)
errors.append(e)
Expand Down
2 changes: 1 addition & 1 deletion musif/extract/features/lyrics/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def update_score_objects(

features[get_part_feature(part, VOICE_PRESENCE)] = len(
part_data[DATA_SOUNDING_MEASURES]
) / len(part_data[DATA_MEASURES])
) / len(part_data[DATA_MEASURES]) if part_data[DATA_MEASURES] else 0

features[get_part_feature(part, SYLLABIC_RATIO)] = get_syllabic_ratio(
part_data[DATA_NOTES], part_data[DATA_LYRICS]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"deepdiff>=6.2.1",
]
name = "musif"
version = "1.2.3"
version = "1.2.4"
description = "Music feature extraction library from the DIDONE project"
authors = [{name = "Didone Project", email = "[email protected]"}]
requires-python = ">=3.10"
Expand Down

0 comments on commit 0df74ca

Please sign in to comment.