crowsetta.formats.seq.timit.Timit#

class crowsetta.formats.seq.timit.Timit(begin_samples: ndarray, end_samples: ndarray, text: ndarray, annot_path: Path, audio_path=None)[source]#

Bases: object

Class that represents annotations from transcription files in the DARPA TIMIT Acoustic-Phonetic Continuous Speech Corpus[1]_.

name#

Shorthand name for annotation format: 'timit'.

Type:

str

ext#

Extension of files in annotation format: ('.phn', '.PHN', '.wrd', '.WRD')

Type:

str

begin_samples#

Vector of integer sample numbers corresponding to beginning of segments, i.e. onsets

Type:

numpy.ndarray

end_samples#

Vector of integer sample numbers corresponding to ends of segments, i.e. offsets

Type:

numpy.ndarray

text#

Vector of string labels for segments; each element is either a single word, or a single phonetic transcription code.

Type:

numpy.ndarray

annot_path#

Path to TIMIT transcription file from which annotations were loaded.

Type:

str, pathlib.Path

audio_path#

Path to audio file that the TIMIT transcription file annotates.

Type:

str. pathlib.Path

References

__init__(begin_samples: ndarray, end_samples: ndarray, text: ndarray, annot_path: Path, audio_path=None) None#

Method generated by attrs for class Timit.

Methods

__init__(begin_samples, end_samples, text, ...)

Method generated by attrs for class Timit.

from_file(annot_path[, audio_path])

Load annotations from a TIMIT[1]_ transcription file.

to_annot([round_times, decimals, samplerate])

Convert this TIMIT annotation to a crowsetta.Annotation.

to_file(annot_path)

Make a phn file in the TIMIT format from this instance.

to_seq([round_times, decimals, samplerate])

Convert this TIMIT annotation to a crowsetta.Sequence.

Attributes

begin_samples

end_samples

text

annot_path

audio_path

ext

name

classmethod from_file(annot_path: str | bytes | PathLike | Path, audio_path: str | bytes | PathLike | Path | None = None) Self[source]#

Load annotations from a TIMIT[1]_ transcription file.

Parameters:
  • annot_path (str, pathlib.Path) – Path to a TIMIT transcription file, with one of the extensions {‘.phn’, ‘.PHN’, ‘.wrd’, ‘.WRD’}.

  • audio_path (str, pathlib.Path) – Optional, defaults to annot_path with the extension changed to ‘.wav’ or ‘.WAV’. Both extensions are checked and if either file exists, that one is used. Otherwise, defaults to ‘.wav’ in lowercase.

Examples

>>> example = crowsetta.data.get('timit')
>>> timit = crowsetta.formats.seq.Timit.from_file(example.annot_path)

Notes

Versions of the dataset exist with the extensions in capital letters. Some platforms may not have case-sensitive paths.

References

to_annot(round_times: bool = True, decimals: int = 3, samplerate: int | None = None) Annotation[source]#

Convert this TIMIT annotation to a crowsetta.Annotation.

Parameters:
  • round_times (bool) – If True, round onsets_s and offsets_s. Default is True.

  • decimals (int) – Number of decimals places to round floating point numbers to. Only meaningful if round_times is True. Default is 3, so that times are rounded to milliseconds.

  • samplerate (int) – Sampling rate for wave files. Used to convert begin_samples and end_samples from sample number to seconds. Default is None, in which ths function tries to open audio_path and determine the actual sampling rate. If this does not work, then the onsets_s and offsets_s attributes of the crowsetta.Sequence are left as None.

Examples

>>> example = crowsetta.data.get('timit')
>>> timit = crowsetta.formats.seq.Timit.from_file(example.annot_path)
>>> annot = timit.to_annot()
Returns:

annot

Return type:

crowsetta.Annotation

Notes

The round_times and decimals arguments are provided to reduce differences across platforms due to floating point error, e.g. when loading annotation files and then sending them to a csv file, the result should be the same on Windows and Linux.

to_file(annot_path: str | bytes | PathLike | Path) None[source]#

Make a phn file in the TIMIT format from this instance.

Parameters:

annot_path (str, pahtlib.Path) – Path including filename where file should be saved. Must have a valid extension for TIMIT transcription files, one of {‘.phn’, ‘.PHN’, ‘.wrd’, ‘.WRD’}.

to_seq(round_times: bool = True, decimals: int = 3, samplerate: int | None = None) Sequence[source]#

Convert this TIMIT annotation to a crowsetta.Sequence.

Parameters:
  • round_times (bool) – if True, round onsets_s and offsets_s. Default is True.

  • decimals (int) – number of decimals places to round floating point numbers to. Only meaningful if round_times is True. Default is 3, so that times are rounded to milliseconds.

  • samplerate (int) – Sampling rate for wave files. Used to convert begin_samples and end_samples from sample number to seconds. Default is None, in which ths function tries to open audio_path and determine the actual sampling rate. If this does not work, then the onsets_s and offsets_s attributes of the crowsetta.Sequence are left as None.

Examples

>>> example = crowsetta.data.get('timit')
>>> timit = crowsetta.formats.seq.Timit.from_file(example.annot_path)
>>> seq = timit.to_seq()
Returns:

phn_seq

Return type:

crowsetta.Sequence

Notes

The round_times and decimals arguments are provided to reduce differences across platforms due to floating point error, e.g. when loading annotation files and then sending them to a csv file, the result should be the same on Windows and Linux.