Skip to content

Commit 70271ba

Browse files
authored
Merge pull request #28 from jsingh811/test-versions
test-versions
2 parents 860da4d + f07ad42 commit 70271ba

File tree

10 files changed

+39
-26
lines changed

10 files changed

+39
-26
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
![pyaudioprocessing](https://user-images.githubusercontent.com/16875926/63388515-8e66fe00-c35d-11e9-98f5-a7ad0478a353.png)
44

55
A Python based library for processing audio data into features and building Machine Learning models.
6-
This was written using `Python 3.7.6`, and should work with python 3.6+.
6+
This was written using `Python 3.7.6`, and has been tested to work with Python >= 3.6, <4.
77

88

99
## Getting Started
@@ -24,12 +24,17 @@ git clone git@github.com:jsingh811/pyAudioProcessing.git
2424
cd pyAudioProcessing
2525
pip install -e .
2626
```
27-
and get the requirements by running
27+
You can also get the requirements by running
2828

2929
```
3030
pip install -r requirements/requirements.txt
3131
```
3232

33+
If you are on Python 3.9 and experience any issues with the code samples regarding numpy, please run
34+
```
35+
pip install -U numpy
36+
```
37+
3338
## Choices
3439

3540
### Feature options

pyAudioProcessing/extract_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def get_features(folder_path, feature_names):
7171

7272
if __name__ == "__main__":
7373
ARGS = PARSER.parse_args()
74-
# dict with stucture
74+
# dict with structure
7575
# {
7676
# <folder name inside ARGS.folder>: {
7777
# <file name> :{

pyAudioProcessing/features/audioFeatureExtraction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def dirsWavFeatureExtraction(dirNames, mt_win, mt_step, st_win, st_step, feats,
252252
'audioData/classSegmentsRec/brush-teeth','audioData/classSegmentsRec/shower'], 1, 1, 0.02, 0.02);
253253
254254
It can be used during the training process of a classification model ,
255-
in order to get feature matrices from various audio classes (each stored in a seperate path)
255+
in order to get feature matrices from various audio classes (each stored in a separate path)
256256
'''
257257

258258
# feature extraction for each class:

pyAudioProcessing/trainer/audioTrainTest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def trainLogisticRegression(features, Cparam):
4646
Train a multi-class probabilitistic Logistic Regression classifier.
4747
Note: This function is simply a wrapper to the sklearn functionality for logistic regression training
4848
ARGUMENTS:
49-
- features: a list ([numOfClasses x 1]) whose elements containt numpy matrices of features
49+
- features: a list ([numOfClasses x 1]) whose elements contain numpy matrices of features
5050
each matrix features[i] of class i is [n_samples x numOfDimensions]
5151
- Cparam: Logistic Regression parameter C (Inverse of regularization strength)
5252
RETURNS:
@@ -65,7 +65,7 @@ def trainLogisticRegression(features, Cparam):
6565
def evaluateclassifier(features, class_names, n_exp, classifier_name, Params, parameterMode, perTrain=0.90):
6666
'''
6767
ARGUMENTS:
68-
features: a list ([numOfClasses x 1]) whose elements containt numpy matrices of features.
68+
features: a list ([numOfClasses x 1]) whose elements contain numpy matrices of features.
6969
each matrix features[i] of class i is [n_samples x numOfDimensions]
7070
class_names: list of class names (strings)
7171
n_exp: number of cross-validation experiments
@@ -239,7 +239,7 @@ def featureAndTrain(list_of_dirs, mt_win, mt_step, st_win, st_step,
239239
'''
240240
This function is used as a wrapper to segment-based audio feature extraction and classifier training.
241241
ARGUMENTS:
242-
list_of_dirs: list of paths of directories. Each directory contains a signle audio class whose samples are stored in seperate WAV files.
242+
list_of_dirs: list of paths of directories. Each directory contains a signle audio class whose samples are stored in separate WAV files.
243243
mt_win, mt_step: mid-term window length and step
244244
st_win, st_step: short-term window and step
245245
classifier_type: "svm" or "knn" or "randomforest" or "gradientboosting" or "extratrees"

requirements/requirements.txt

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,4 @@ eyed3==0.9.5
77
pydub==0.23.1
88
pyAudioAnalysis==0.2.5
99
pytest==6.2.3
10-
rsa==4.7
11-
bleach==3.3.0
12-
docutils==0.17.1
13-
Pygments==2.8.1
14-
jmespath==0.9.5
15-
urllib3==1.26.4
16-
colorama==0.4.3
17-
PyYAML==5.4.1
18-
requests==2.25.1
19-
tqdm==4.60.0
20-
pkginfo==1.7.0
21-
keyring==23.0.1
10+
ffmpeg==1.4

tests/__init__.py

Whitespace-only changes.

tests/test_classification.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/test_data/speech/nearhou.wav

1.26 MB
Binary file not shown.

tests/test_data/speech/sleep.wav

1.26 MB
Binary file not shown.

tests/test_feature_extraction.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Fri Apr 30 17:37:32 2021
5+
6+
@author: jsingh
7+
"""
8+
import os
9+
import pytest
10+
from pathlib import Path
11+
from pyAudioProcessing.extract_features import get_features
12+
13+
def test_get_features():
14+
"""
15+
Test get_features function
16+
"""
17+
test_root = str(Path(__file__).parent)
18+
data_dir = os.path.join(test_root, "test_data")
19+
features = get_features(data_dir, ["gfcc", "mfcc"])
20+
assert "speech" in features
21+
assert len([i for i in features["speech"].keys() if "sleep.wav" in i]) > 0
22+
key = list(features["speech"].keys())[0]
23+
assert "features" in features["speech"][key]
24+
assert "feature_names" in features["speech"][key]
25+
assert "mfcc_1_mean" in features["speech"][key]["feature_names"]
26+
assert "gfcc_1_mean" in features["speech"][key]["feature_names"]

0 commit comments

Comments
 (0)