GithubHelp home page GithubHelp logo

deeplearningsprint / ba-dls-deepspeech Goto Github PK

View Code? Open in Web Editor NEW

This project forked from baidu-research/ba-dls-deepspeech

0.0 2.0 0.0 70.17 MB

License: Apache License 2.0

Python 98.38% Shell 1.62%

ba-dls-deepspeech's Introduction

ba-dls-deepspeech

Train your own CTC model! This code was released with the lecture from the Bay Area DL School. PDF slides are available here.

Table of Contents

  1. Dependencies
  2. Data
  3. Running an example

Dependencies

You will need the following packages installed before you can train a model using this code. You may have to change PYTHONPATH to include the directories of your new packages.

theano
The underlying deep learning Python library. We suggest downloading the latest release from https://github.com/Theano/Theano/releases.

$tar xf <downloaded_tar_file>
$cd theano-*
$python setup.py install --user

keras
This is a wrapper over Theano that provides nice functions for building networks. Download the latest release from https://github.com/fchollet/keras/releases
Make sure you install it with support for hdf5 - we make use of that to save models.

$tar xf <downloaded_tar_file>
$cd keras-*
$python setup.py install --user

lasagne

$pip install lasagne <--user>

warp-ctc
This contains the main implementation of the CTC cost function.
git clone https://github.com/baidu-research/warp-ctc
To install it, follow the instructions on https://github.com/baidu-research/warp-ctc

theano-warp-ctc
This is a theano wrapper over warp-ctc.
git clone https://github.com/sherjilozair/ctc
Follow the instructions on https://github.com/sherjilozair/ctc for installation.

Others
You may require some additional packages. Install Python requirements through pip as:
pip install soundfile
On Ubuntu, avconv (used here for audio format conversions) requires libav-tools.
sudo apt-get install libav-tools

Data

We will make use of the LibriSpeech ASR corpus to train our models. While you can start off by using the 'clean' LibriSpeech datasets, you can use the download.sh script to download the entire corpus (~65GB). Use flac_to_wav.sh to convert any flac files to wav.
We make use of a JSON file that aggregates all data for training, validation and testing. Once you have a corpus, create a description file that is a json-line file in the following format:

{"duration": 15.685, "text": "spoken text label", "key": "/home/username/LibriSpeech/train-clean-360/5672/88367/5672-88367-0031.wav"}
{"duration": 14.32, "text": "ground truth text", "key": "/home/username/LibriSpeech/train-other-500/8678/280914/8678-280914-0009.wav"}

You can create such a file using create_desc_file.py.

$python create_desc_file.py /path/to/LibriSpeech/train-clean-100 train_corpus.json
$python create_desc_file.py /path/to/LibriSpeech/dev-clean validation_corpus.json
$python create_desc_file.py /path/to/LibriSpeech/test-clean test_corpus.json

You can query the duration of a file using: soxi -D filename.

Running an example

Training
Finally, let's train a model!

$python train.py train_corpus.json validation_corpus.json /path/to/model

This will checkpoint a model every few iterations into the directory you specify. You can monitor how your model is doing, using plot.py.

$python plot.py -d /path/to/model1 /path/to/model2 -s plot.png

This will save a plot comparing two models' training and validation performance over iterations. This helps you gauge hyperparameter settings and their effects. Eg: You can change learning rate passed to compile_train_fn in train.py, and see how that affects training curves. Note that the model and costs are checkpointed only once in 500 iterations or once every epoch, so it may take a while before you can see updates plots.

Testing
Once you've trained your model for a sufficient number of iterations, you can test its performance on a different dataset:

$python test.py test_corpus.json train_corpus.json /path/to/model

This will output the average loss over the test set, and the predictions compared to their ground truth. We make use of the training corpus here, to compute feature means and variance.

Visualization/Debugging
You can also visualize your model's outputs for an audio clip using:

$python visualize.py audio_clip.wav train_corpus.json /path/to/model

This outputs: softmax.png and softmax.npy. These will tell you how confident your model is about the ground truth, across all the timesteps.

ba-dls-deepspeech's People

Contributors

apcoates avatar jfsantos avatar srvinay avatar

Watchers

 avatar  avatar

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.