Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bagustris/nkululeko
Browse files Browse the repository at this point in the history
  • Loading branch information
bagustris committed May 8, 2024
2 parents c09a4b1 + 6aab034 commit 19fc688
Show file tree
Hide file tree
Showing 67 changed files with 988 additions and 558 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/basic_tests_for_aud_csv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ jobs:
- name: Run csv-ravdess-praat-xgb
run: |
cd data/ravdess
wget https://zenodo.org/record/1188976/files/Audio_Speech_Actors_01-24.zip
unzip Audio_Speech_Actors_01-24.zip
# wget https://zenodo.org/record/1188976/files/Audio_Speech_Actors_01-24.zip
wget https://zenodo.org/records/11063852/files/Audio_Speech_Actors_01-24_16k.zip
unzip Audio_Speech_Actors_01-24_16k.zip
cd ../..
python3 -m nkululeko.nkululeko --config data/ravdess/exp_praat_xgb.ini > output1.txt
if grep -q "DONE" output1.txt; then
Expand Down
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,43 @@
Changelog
=========

Version 0.84.0
--------------
* added SHAP analysis
* started with finetuning

Version 0.83.3
--------------
* fixed a naming error in trill features that prevented storage of experiment

Version 0.83.2
--------------
* added default cuda if present and not stated

Version 0.83.1
--------------
* add test module to nkuluflag

Version 0.83.0
--------------
* test module now prints out reports

Version 0.82.4
--------------
* fixed bug in wavlm

Version 0.82.3
--------------
* fixed another audformat peculiarity to interprete time values as nanoseconds

Version 0.82.2
--------------
* fixed audformat peculiarity that dataframes can have only one column

Version 0.82.1
--------------
* Add more test for GC action

Version 0.82.0
--------------
* added nkuluflag module
Expand Down
72 changes: 72 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Code of Conduct

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, education, socioeconomic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* using welcoming and inclusive language,
* being respectful of differing viewpoints and experiences,
* gracefully accepting constructive criticism,
* focusing on what is best for the community, and
* showing empathy towards other community members.

Examples of unacceptable behavior by participants include:

* the use of sexualized language or imagery and unwelcome sexual
attention or advances,
* trolling, insulting/derogatory comments, and personal or political
attacks,
* public or private harassment,
* publishing others' private information, such as a physical or
electronic address, without explicit permission, and
* other conduct which could reasonably be considered inappropriate in
a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project email
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by emailing the project team. All complaints will be reviewed
and investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. The project team is obligated to maintain
confidentiality with regard to the reporter of an incident. Further details of
specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][contributor_covenant]
version 1.4.

[contributor_covenant]: https://www.contributor-covenant.org/
2 changes: 1 addition & 1 deletion data/crema-d/load_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
audb.config.CACHE_ROOT = cwd

# load the latest version of the data
db = audb.load("crema-d", format="wav", sampling_rate=16000, mixdown=True)
db = audb.load("crema-d", version="1.3.0", verbose=True)
4 changes: 4 additions & 0 deletions data/ravdess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ I used the version downloadable from [Zenodo](https://zenodo.org/record/1188976)

Download and unzip the file Audio_Speech_Actors_01-24.zip
```bash
# download original dataset in 48k
$ wget https://zenodo.org/record/1188976/files/Audio_Speech_Actors_01-24.zip
$ unzip Audio_Speech_Actors_01-24.zip
```

Or, if you prefer the dataset in 16k, you can download from this link:
https://zenodo.org/records/11063852/files/Audio_Speech_Actors_01-24_16k.zip

run the file
```bash
python3 process_database.py
Expand Down
2 changes: 2 additions & 0 deletions data/ravdess/exp_praat_xgb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ dev = ./data/ravdess/ravdess_dev.csv
dev.type = csv
dev.absolute_path = False
dev.split_strategy = train
dev.audio_path = Audio_Speech_Actors_01-24_16k/
test = ./data/ravdess/ravdess_test.csv
test.type = csv
test.absolute_path = False
test.split_strategy = test
test.audio_path = Audio_Speech_Actors_01-24_16k/
target = emotion
labels = ['angry', 'happy', 'neutral', 'sad']
[FEATS]
Expand Down
4 changes: 3 additions & 1 deletion ini_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@
* **dist_type**: type of plot for value counts, either histogram or density estimation (kde)
* dist_type = hist
* **spotlight**: open a web-browser window to inspect the data with the [spotlight software](https://github.com/Renumics/spotlight). Needs package *renumics-spotlight* to be installed!
* spotlight = False
* spotlight = False
* **shap**: comopute [SHAP](https://shap.readthedocs.io/en/latest/) values
* shap = False
### [PREDICT](#predict)
* **targets**: Speaker/speech characteristics to be predicted by some models
* targets = ['gender', 'age', 'snr', 'arousal', 'valence', 'dominance', 'pesq', 'mos']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
# {'--feat': 'os',
# '--set': 'ComParE_2016',
# },
{"--feat": "audmodel"},
{"--feat": "praat"},
]


for c in classifiers:
for f in features:
cmd = "python -m nkululeko.nkuluflag --config exp.ini "
cmd = "python -m nkululeko.nkuluflag --config meta/demos/multiple_exeriments/exp.ini "
for item in c:
cmd += f"{item} {c[item]} "
for item in f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ emodb.train_tables = ['emotion.categories.train.gold_standard']
emodb.test_tables = ['emotion.categories.test.gold_standard']
target = emotion
labels = ['anger', 'happiness']
tests = ['emodb']
[FEATS]
[MODEL]
C_val = .001
Expand Down
28 changes: 28 additions & 0 deletions meta/demos/multiple_experiments/tmp.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[EXP]
root = ./
name = results
runs = 1
epochs = 1

[DATA]
databases = ['emodb']
emodb = ../../../data/emodb/emodb
emodb.split_strategy = specified
emodb.train_tables = ['emotion.categories.train.gold_standard']
emodb.test_tables = ['emotion.categories.test.gold_standard']
target = emotion
labels = ['anger', 'happiness']

[FEATS]
type = ['praat']

[MODEL]
c_val = .001
learning_rate = 0.0001
store = True
patience = 5
type = svm

[PLOT]
best_model = True

194 changes: 194 additions & 0 deletions meta/demos/result_visualization/plot_multiple_experiment_results.ipynb

Large diffs are not rendered by default.

Binary file added meta/images/results_dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion nkululeko/constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION="0.82.0"
VERSION="0.84.0"
SAMPLING_RATE = 16000
13 changes: 12 additions & 1 deletion nkululeko/data/dataset_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,18 @@ def load(self):
# data_file = os.path.join(exp_root, data_file)
root = os.path.dirname(data_file)
audio_path = self.util.config_val_data(self.name, "audio_path", "")
df = audformat.utils.read_csv(data_file)
df = pd.read_csv(data_file)
# special treatment for segmented dataframes with only one column:
if "start" in df.columns and len(df.columns) == 4:
index = audformat.segmented_index(
df.file.values, df.start.values, df.end.values
)
df = df.set_index(index)
df = df.drop(columns=["file", "start", "end"])
else:
df = audformat.utils.read_csv(data_file)
if isinstance(df, pd.Series):
df = df.to_frame()
rename_cols = self.util.config_val_data(self.name, "colnames", False)
if rename_cols:
col_dict = ast.literal_eval(rename_cols)
Expand Down
13 changes: 6 additions & 7 deletions nkululeko/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# Demonstration code to use the ML-experiment framework
# Test the loading of a previously trained model and demo mode
# needs the project config file to run before
"""
This script is used to test the loading of a previously trained model and run it in demo mode.
"""This script is used to test the loading of a previously trained model.
And run it in demo mode.
It requires the project config file to be run before.
Usage:
Expand All @@ -20,17 +21,15 @@
import configparser
import os

import nkululeko.glob_conf as glob_conf
from nkululeko.constants import VERSION
from nkululeko.experiment import Experiment
import nkululeko.glob_conf as glob_conf
from nkululeko.utils.util import Util


def main(src_dir):
parser = argparse.ArgumentParser(
description="Call the nkululeko DEMO framework.")
parser.add_argument("--config", default="exp.ini",
help="The base configuration")
parser = argparse.ArgumentParser(description="Call the nkululeko DEMO framework.")
parser.add_argument("--config", default="exp.ini", help="The base configuration")
parser.add_argument(
"--file", help="A file that should be processed (16kHz mono wav)"
)
Expand Down
7 changes: 4 additions & 3 deletions nkululeko/demo_predictor.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# demo_predictor.py
import os

import audformat
import audiofile
import numpy as np
import pandas as pd

import audformat
import audiofile

import nkululeko.glob_conf as glob_conf
from nkululeko.utils.util import Util


class Demo_predictor:
def __init__(self, model, file, is_list, feature_extractor, label_encoder, outfile):
"""Constructor setting up name and configuration"""
"""Constructor setting up name and configuration."""
self.model = model
self.feature_extractor = feature_extractor
self.label_encoder = label_encoder
Expand Down
Loading

0 comments on commit 19fc688

Please sign in to comment.