-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a1bd63
commit 51836c5
Showing
3 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
build: | ||
python_version: "3.6" | ||
gpu: false | ||
python_packages: | ||
- pandas==1.1.5 | ||
- numpy==1.17.3 | ||
- wave==0.0.2 | ||
- sklearn==0.0 | ||
- librosa==0.6.3 | ||
- soundfile==0.9.0 | ||
- tqdm==4.28.1 | ||
- matplotlib==2.2.3 | ||
- pyaudio==0.2.11 | ||
- numba==0.48 | ||
system_packages: | ||
- "ffmpeg" | ||
- "portaudio19-dev" | ||
predict: "predict.py:EmoPredictor" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import json | ||
import os | ||
import tempfile | ||
from pathlib import Path | ||
|
||
import cog | ||
from emotion_recognition import EmotionRecognizer | ||
|
||
|
||
class EmoPredictor(cog.Predictor): | ||
def setup(self): | ||
"""Load the emotion recognition model and (quickly) train it""" | ||
# self.rec = EmotionRecognizer(None, emotions=["boredom", "neutral"], features=["mfcc"]) | ||
self.rec = EmotionRecognizer( | ||
None, | ||
emotions=["sad", "neutral", "happy"], | ||
features=["mfcc"], | ||
probability=True, | ||
) | ||
# evaluate all models in `grid` folder and determine the best one in terms of test accuracy | ||
self.rec.determine_best_model() | ||
|
||
@cog.input("input", type=Path, help="Speech audio file") | ||
def predict(self, input): | ||
"""Compute emotion prediction""" | ||
prediction = self.rec.predict_proba(str(input)) | ||
|
||
return prediction |