audiomate.formats

This module contains code for working with different file formats.

Audacity Labels

audiomate.formats.audacity.read_label_file(path)[source]

Read the labels from an audacity label file.

Parameters:path (str) – Path to the label file.
Returns:List of labels (start [sec], end [sec], label)
Return type:list

Example:

>>> read_label_file('/path/to/label/file.txt')
[
    [0.0, 0.2, 'sie'],
    [0.2, 2.2, 'hallo']
]
audiomate.formats.audacity.read_label_list(path)[source]

Reads labels from an Audacity label file and returns them wrapped in a audiomate.corpus.assets.LabelList.

Parameters:path (str) – Path to the Audacity label file
Returns:Label list containing the labels
Return type:audiomate.corpus.assets.LabelList
audiomate.formats.audacity.write_label_file(path, entries)[source]

Writes an audacity label file. Start and end times are in seconds.

Parameters:
  • path (str) – Path to write the file to.
  • entries (list) – List with entries to write.

Example:

>>> data = [
>>>     [0.0, 0.2, 'sie'],
>>>     [0.2, 2.2, 'hallo']
>>> ]
>>>
>>> write_label_file('/some/path/to/file.txt', data)
audiomate.formats.audacity.write_label_list(path, label_list)[source]

Writes the given label_list to an audacity label file.

Parameters:

CTM Files

audiomate.formats.ctm.read_file(path)[source]

Reads a ctm file.

Parameters:path (str) – Path to the file
Returns:Dictionary with entries.
Return type:(dict)

Example:

>>> read_file('/path/to/file.txt')
{
    'wave-ab': [
        ['1', 0.00, 0.07, 'HI', 1],
        ['1', 0.09, 0.08, 'AH', 1]
    ],
    'wave-xy': [
        ['1', 0.00, 0.07, 'HI', 1],
        ['1', 0.09, 0.08, 'AH', 1]
    ]
}
audiomate.formats.ctm.write_file(path, entries)[source]

Writes a ctm file.

Parameters:
  • path (str) – Path to write the file to.
  • entries (list) – List with entries to write. (entries -> wave-file, channel, start (seconds), duration (seconds), label)

Example:

>>> data = [
>>>     ["wave-ab", '1', 0.0, 0.82, "duda"],
>>>     ["wave-xy", '1', 0.82, 0.57, "Jacques"],
>>> ]
>>>
>>> write_file('/path/to/file.txt', data)