Coder Social home page Coder Social logo

oscarknagg / raw-audio-gender-classification Goto Github PK

View Code? Open in Web Editor NEW
21.0 2.0 6.0 3.92 MB

Machine learning experiment to perform gender classification from raw audio.

Python 100.00%
machine-learning gender-classification convolutional-neural-networks pytorch audio speech

raw-audio-gender-classification's Introduction

raw-audio-gender-classification

This project contains the code to train a gender classification model that takes raw audio as inputs.

The weights of the model from the article can be found in the models/ directory.

See my Medium article for more discussion.

Instructions

Requirements

Make a new virtualenv and install requirements from requirements.txt with

pip install -r requirements.txt

This project was written in Python 2.7.12 so I cannot guarantee it works on any other version.

Run tests

python -m unittest tests

Data

Get training data here: http://www.openslr.org/12

  • train-clean-100.tar.gz
  • train-clean-360.tar.gz
  • dev-clean.tar.gz

Place the unzipped training data into the data/ folder so the file structure is as follows:

data/
    LibriSpeech/
        dev-clean/
        train-clean-100/
        train-clean-360/
        SPEAKERS.TXT

Please use the SPEAKERS.TXT supplied in the repo as I've made a few corrections to the one found at openslr.org.

Training

Run run_experiment.py with the default parameters to train the model with the performance discussed in the article.

Processing audio

Run process_audio.py, specifying the model and audio file to use. The audio file must be a .flac file.

This script makes many predictions on different fragments of the target audio file and saves the results to data/results.csv.

I used this script to produce the data for the video embedded in the Medium article.

Notebooks

I have uploaded two notebooks with this project.

Model_Performance_Investigation gives a breakdown of the performance of the model over the different speakers in the LibriSpeech dataset.

Interview_Segmentation is where I analysed the results of the process_audio.py script on an interview between Elton John and Kirsty Wark.

raw-audio-gender-classification's People

Contributors

oscarknagg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

raw-audio-gender-classification's Issues

TypeError: __init__() got multiple values for keyword argument 'data_format' (pretrained model)

'Loading and Visualisation Pretrained model"
model_path= '../models/n_seconds/siamese__nseconds_3.0__filters_32__embed_64__drop_0.05__r_0.hdf5'
downsampling = 4

siamese = load_model(model_path)

********************************************error

TypeError Traceback (most recent call last)
in ()
----> 1 siamese = load_model(model_path)

/opt/conda/lib/python3.6/site-packages/keras/models.py in load_model(filepath, custom_objects, compile)
237 raise ValueError('No model found in config file.')
238 model_config = json.loads(model_config.decode('utf-8'))
--> 239 model = model_from_config(model_config, custom_objects=custom_objects)
240
241 # set weights

/opt/conda/lib/python3.6/site-packages/keras/models.py in model_from_config(config, custom_objects)
311 'Maybe you meant to use '
312 'Sequential.from_config(config)?')
--> 313 return layer_module.deserialize(config, custom_objects=custom_objects)
314
315

/opt/conda/lib/python3.6/site-packages/keras/layers/init.py in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')

/opt/conda/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
137 return cls.from_config(config['config'],
138 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 139 list(custom_objects.items())))
140 with CustomObjectScope(custom_objects):
141 return cls.from_config(config['config'])

/opt/conda/lib/python3.6/site-packages/keras/engine/topology.py in from_config(cls, config, custom_objects)
2485 # First, we create all layers and enqueue nodes to be processed
2486 for layer_data in config['layers']:
-> 2487 process_layer(layer_data)
2488 # Then we process nodes in order of layer depth.
2489 # Nodes that cannot yet be processed (if the inbound node

/opt/conda/lib/python3.6/site-packages/keras/engine/topology.py in process_layer(layer_data)
2471
2472 layer = deserialize_layer(layer_data,
-> 2473 custom_objects=custom_objects)
2474 created_layers[layer_name] = layer
2475

/opt/conda/lib/python3.6/site-packages/keras/layers/init.py in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')

/opt/conda/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
137 return cls.from_config(config['config'],
138 custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 139 list(custom_objects.items())))
140 with CustomObjectScope(custom_objects):
141 return cls.from_config(config['config'])

/opt/conda/lib/python3.6/site-packages/keras/models.py in from_config(cls, config, custom_objects)
1211 model = cls()
1212 for conf in config:
-> 1213 layer = layer_module.deserialize(conf, custom_objects=custom_objects)
1214 model.add(layer)
1215 return model

/opt/conda/lib/python3.6/site-packages/keras/layers/init.py in deserialize(config, custom_objects)
52 module_objects=globs,
53 custom_objects=custom_objects,
---> 54 printable_module_name='layer')

/opt/conda/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
139 list(custom_objects.items())))
140 with CustomObjectScope(custom_objects):
--> 141 return cls.from_config(config['config'])
142 else:
143 # Then cls may be a function returning a class.

/opt/conda/lib/python3.6/site-packages/keras/engine/topology.py in from_config(cls, config)
1250 A layer instance.
1251 """
-> 1252 return cls(**config)
1253
1254 def count_params(self):

/opt/conda/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
85 warnings.warn('Update your ' + object_name + 86 ' call to the Keras 2 API: ' + signature, stacklevel=2)
---> 87 return func(*args, **kwargs)
88 wrapper._original_function = func
89 return wrapper

/opt/conda/lib/python3.6/site-packages/keras/layers/convolutional.py in init(self, filters, kernel_size, strides, padding, dilation_rate, activation, use_bias, kernel_initializer, bias_initializer, kernel_regularizer, bias_regularizer, activity_regularizer, kernel_constraint, bias_constraint, **kwargs)
331 kernel_constraint=kernel_constraint,
332 bias_constraint=bias_constraint,
--> 333 **kwargs)
334 self.input_spec = InputSpec(ndim=3)
335

TypeError: init() got multiple values for keyword argument 'data_format'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.