GithubHelp home page GithubHelp logo

danspeech_training's Introduction

DanSpeech Training add-on

Repository structure

DanSpeech training is an add-on repository to the DanSpeech package. It was developed to help development cycles.

DanSpeech training supports modes:

  1. train new model from scratch - train_new.py
  2. continue training an existing model - train_continue.py
  3. finetune an existing model - finetune.py

Furthermore, to evaulate models use the evaluate.py script.

All training and testing requires a specific file structure.

  1. All audio files associated with a particular task must be placed inside a folder (e.g. /home/usr/project_folder/train/ for training associated files).
  2. Each task associated folder must include exactly one .csv file, each row in the .csv file is expected to point to exactly one audio file and contain all relevant information associated with the file it points to (e.g. /home/usr/project_folder/train/overview.csv).

Installation

To run the training code, follow the steps below. We suggest using a virtual environment.

  1. Install danspeech
  2. Install wget through pip
  3. Install python bindings for warp-ctc

To use beam search decoding, you need ctc-decode as well.

The training repo has quite a lot of dependencies, hence this repo includes the env_train.yml file with versions for all dependencies in a working virtual conda environment. If you have trouble, look at the file for the specific versions or try to install a virtual conda environment with:

conda env create -f env_train.yml

Python bindings for warp-ctc always needs to be installed manually.

For multi GPU you additionally need apex

And example of a csv file could be:

file,trans
filename.wav,pandaer er et fantastisk dyr jeg ville ønske de kunne snakke dansk
filenmae1.wav,koalaer er søde jeg ville ønske de kunne snakke dansk
...
filenamen.wav,pindsvin er flotte jeg ville ønske de ikke stak så meget

Due to current implementation, audio files need to be placed in same directory as the csv file.

Example use-cases:

Training with a CPU is default. To train with GPU parse --use_gpu to script.

See the args for each of the scripts for more information towards what you can parse.

Evaluate an existing model

python evaluate.py --model_path ~/.danspeech/models/TestModel.pth --test_dataset ~/data/nst/preprocessed_test --transcriptions_out_file test.csv --use_gpu --batch_size 128 --beam_width 20 --decoder beam --lm_path ~/.danspeech/lms/dsl_3gram.klm --alpha 0.7

Training a new model

python train_new.py --model_id test_id --train_data_path ~/data/nst/preprocessed_test --validation_data_path ~/data/nst/preprocessed_test --save_dir test_results --use_gpu --epochs 40 --batch_size 16 --train_with_augmentations 

Continue training an existing model

python train_continue.py --model_id test_id --train_data_path ~/data/nst/preprocessed_test --validation_data_path ~/data/nst/preprocessed_test --save_dir test_results --use_gpu --epochs 40 --batch_size 16 --train_with_augmentations --continue_from_path ~/home/models/dummy.pth

Finetuning

python finetune.py --model_id test_id --train_data_path ~/data/nst/preprocessed_test --validation_data_path ~/data/nst/preprocessed_test --save_dir test_results --use_gpu --epochs 40 --batch_size 16 --train_with_augmentations --stored_model_path ~/home/models/dummy.pth

Finetuning DanSpeech models

python finetune.py --model_id test_id --train_data_path ~/data/nst/preprocessed_test --validation_data_path ~/data/nst/preprocessed_test --save_dir test_results --use_gpu --epochs 40 --batch_size 16 --train_with_augmentations --danspeech_model DanSpeechPrimary 

Authors and acknowledgment

Main authors:

This project is supported by Innovation Foundation Denmark through the projects DABAI and ATEL

Other acknowledgements:

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.