Home

Awesome

Punctuator

An LSTM RNN for restoring missing punctuation in text. There's now a bidirectional model also available: https://github.com/ottokart/punctuator2

Model is trained in two stages (second stage is optional though):

  1. First stage is trained on punctuation annotated text. Here the model learns to restore puncutation based on textual features only.
  2. Optional second stage can be trained on punctuation and pause annotated text. In this stage the model learns to combine pause durations with textual features and adapts to the target domain. If pauses are omitted then only adaptation is performed. Second stage with pause durations can be used for example for restoring punctuation in automatic speech recognition system output.

Requirements

Requirements for data:

Make sure that first words of sentences don't have capitalized first letters. This would give the model unfair hints about period locations.

Configuration

Configuration is located in conf.py.

Punctuation annotation symbols are specified in the PUNCTUATIONS dictionary. .PERIOD and ,COMMA are the default and the dictionary should also include space (no punctuation).

Location of the vocabulary file is specified in VOCABULARY_FILE.

The locations of the data files can be configured in PHASE1['TRAIN_DATA'], PHASE1['DEV_DATA'], PHASE2['TRAIN_DATA'] and PHASE2['DEV_DATA'].

Changing some configuration options (batch size, data files, pause usage, punctuations or vocabulary) may require deleting the data directory so the data files will be reconverted during the next run.

Usage

Run python main.py <model_name>.

Model name is optional. Default is 'model'.

A small example dataset is also included.

Tools might not work properly yet!

Citing

The software is described in this paper:

@inproceedings{tilk2015,
  author    = {Ottokar Tilk and Tanel Alum{\"a}e},
  title     = {{LSTM} for Punctuation Restoration in Speech Transcripts},
  booktitle = {Interspeech 2015},
  year      = {2015},
  address   = {Dresden, Germany}
}