# Path: praatio/textgrid.py
# def openTextgrid(
#     fnFullPath: str,
#     includeEmptyIntervals: bool,
#     reportingMode: Literal["silence", "warning", "error"] = "warning",
#     duplicateNamesMode: Literal["error", "rename"] = "error",
# ) -> Textgrid:
# def _dictionaryToTg(
#     tgAsDict: dict, reportingMode: Literal["silence", "warning", "error"]
# ) -> Textgrid:


import os
from os.path import join
from praatio import textgrid
"""
Extracts the duration of each interval in each tier of the specified textgrids

Outputs the data in a csv friendly format
"""



path = join(".", "files")
for fn in ["bobby_phones.TextGrid", "bobby_words.TextGrid", "mary.TextGrid"]:
    tg = textgrid.openTextgrid(join(path, fn), False)
    name = os.path.splitext(fn)[0]

    # Get the durations for each tier
    for tierName in tg.tierNameList:
        tier = tg.tierDict[tierName]

# Path: praatio/textgrid.py
# def openTextgrid(
#     fnFullPath: str,
#     includeEmptyIntervals: bool,
#     reportingMode: Literal["silence", "warning", "error"] = "warning",
#     duplicateNamesMode: Literal["error", "rename"] = "error",
# ) -> Textgrid:
# def _dictionaryToTg(
#     tgAsDict: dict, reportingMode: Literal["silence", "warning", "error"]
# ) -> Textgrid:


# Path: examples/calculate_duration.py
import os
from os.path import join
from praatio import textgrid

"""
Extracts the duration of each interval in each tier of the specified textgrids

Outputs the data in a csv friendly format
"""



path = join(".", "files")
for fn in ["bobby_phones.TextGrid", "bobby_words.TextGrid", "mary.TextGrid"]:
    tg = textgrid.openTextgrid(join(path, fn), False)
    name = os.path.splitext(fn)[0]

    # Get the durations for each tier
    for tierName in tg.tierNameList:
        tier = tg.tierDict[tierName]

        if not isinstance(tier, textgrid.IntervalTier):