Sign inSign up

stevemurr/gencl

By stevemurr

Updated over 8 years ago

Gender and Emotion Classifier

Image
0

159

stevemurr/gencl repository overview

Gender and Emotion Classifier

Web service for classifying audio samples.

Installation

The easiest way is to use docker.

Pull the image:

docker pull stevemurr/gencl

Run the image in the foreground:

docker run -p 8000:8000 -it stevemurr/gencl

Gender Classifier

Classify any audio sample as either a Male or Female sample.

Usage

You can:

  1. POST request with audio data in the body.
  2. POST request with audio data in the file form field.

Successful response for /gender endpoint looks like:

{
    "class_names": [
        "Male",
        "Female"
    ],
    "confidence": 0.9979417281844198,
    "predicted": "Male",
    "probabilities": [
        0.9979417281844198,
        0.0020582718155802244
    ],
    "result": 0.0
}
HTTP

I prefer http over curl.

Some abridged installation instructions for http:
OSX

brew install httpie

Linux

apt-get install httpie
dnf install httpie
yum install httpie
pacman -S httpie

Windows

pip install --upgrade pip setuptools
pip install --upgrade httpie

In the body:
http -f POST http://localhost:8000/gender < file-to-classify.wav

As a form:
http -f POST http://localhost:8000/gender file@~/Desktop/file-to-classify.wav

This form flow is the html equivalent of:

HTML
<form enctype="multipart/form-data" method="post" action="http://localhost:8000/gender">
    <input type="file" name="file" />
</form>
Javascript / Fetch
var headers = new Headers();
// modify headers as needed
// headers.append("Content-Type", "");
var formData = new FormData();
formData.append("file", data);

var options = {
    method: 'POST',
    headers: headers,
    body: formData,
}

fetch("http://localhost:8000/gender", options).then((res) => {
    return res.json();
}).then((j) => {
    console.log(j)
}).catch((err) => {
    console.log(err)
})
Python
import requests

with open("file-to-classify.wav", "r") as f:
    r = requests.post("http://localhost:8000/gender", data=f.read())
print(r.json())

Emotion Classifier

Accepts speech audio as input and returns arousal and valence. Arousal denotes intensity and valence denotes emotional affectivity.

X axis is valence Y axis is arousal

A basic cheat sheet for interpreting values could be:

Intense & Sad   | Intense & Emotional  
(-, +)          | (+, +)
                |
-------------------------------------
Somber & Sad    | Somber & Emotional
(-, -)          | (+, -)
                |

Usage

Successful response for /emotion endpoint looks like:

{
    "arousal": -0.44036897518838625,
    "class_names": [
        "arousal",
        "valence"
    ],
    "result": [
        -0.44036897518838625,
        -0.25920978580531595
    ],
    "valence": -0.25920978580531595
}

In the body:
http -f POST http://localhost:8000/emotion < file-to-classify.wav

As a form:
http -f POST http://localhost:8000/emotion file@~/Desktop/file-to-classify.wav

This form flow is the html equivalent of:

HTML
<form enctype="multipart/form-data" method="post" action="http://localhost:8000/emotion">
    <input type="file" name="file" />
</form>
Javascript / Fetch
var headers = new Headers();
// modify headers as needed
// headers.append("Content-Type", "");
var formData = new FormData();
formData.append("file", data);

var options = {
    method: 'POST',
    headers: headers,
    body: formData,
}

fetch("http://localhost:8000/emotion", options).then((res) => {
    return res.json();
}).then((j) => {
    console.log(j)
}).catch((err) => {
    console.log(err)
})
Python
import requests

with open("file-to-classify.wav", "r") as f:
    r = requests.post("http://localhost:8000/emotion", data=f.read())
print(r.json())

Tag summary

Content type

Image

Digest

Size

339.1 MB

Last updated

over 8 years ago

docker pull stevemurr/gencl