File#

class montreal_forced_aligner.db.File(**kwargs)[source]#

Bases: Base

Database class for storing information about files in the corpus

Parameters:
  • id (int) – Primary key

  • name (str) – Base name of the file

  • relative_path (Path) – Path of the file relative to the root corpus directory

  • modified (bool) – Flag for whether the file has been changed in the database for exporting

  • text_file (TextFile) – TextFile object with information about the transcript of a file

  • sound_file (SoundFile) – SoundFile object with information about the audio of a file

  • speakers (list[Speaker]) – Speakers in the file ordered by their index

  • utterances (list[Utterance]) – Utterances in the file

construct_transcription_tiers(original_text=False)[source]#

Construct output transcription tiers for the file

Returns:

Tier dictionary of utterance transcriptions

Return type:

dict[str, dict[str, list[CtmInterval]]]

property duration#

Duration of the associated sound file

property num_channels#

Number of channels of the associated sound file

property num_speakers#

Number of speakers in the file

property num_utterances#

Number of utterances in the file

property sample_rate#

Sample rate of the associated sound file

save(output_directory, output_format=None, save_transcription=False, overwrite=False)[source]#

Output File to TextGrid or lab. If text_type is not specified, the original file type will be used, but if there was no text file for the file, it will guess lab format if there is only one utterance, otherwise it will output a TextGrid file.

Parameters:
  • output_directory (str) – Directory to output file, if None, then it will overwrite the original file

  • output_format (str, optional) – Text type to save as, if not provided, it will use either the original file type or guess the file type

  • save_transcription (bool) – Flag for whether the hypothesized transcription text should be saved instead of the default text