# Path: praatio/praatio_scripts.py
# class NameStyle:
#     APPEND = "append"
#     APPEND_NO_I = "append_no_i"
#     LABEL = "label"
# def _shiftTimes(
#     tg: textgrid.Textgrid, timeV: float, newTimeV: float
# ) -> textgrid.Textgrid:
# def audioSplice(
#     audioObj: audio.WavObj,
#     spliceSegment: audio.WavObj,
#     tg: textgrid.Textgrid,
#     tierName: str,
#     newLabel: str,
#     insertStart: float,
#     insertStop: float = None,
#     alignToZeroCrossing: bool = True,
# ) -> Tuple[audio.WavObj, textgrid.Textgrid]:
# def spellCheckEntries(
#     tg: textgrid.Textgrid,
#     targetTierName: str,
#     newTierName: str,
#     checkFunction: Callable[[str], bool],
#     printEntries: bool = False,
# ) -> textgrid.Textgrid:
# def splitTierEntries(
#     tg: textgrid.Textgrid,
#     sourceTierName: str,
#     targetTierName: str,
#     startT: float = None,
#     endT: float = None,
# ) -> textgrid.Textgrid:
# def tgBoundariesToZeroCrossings(
#     tg: textgrid.Textgrid,
#     wavObj: audio.WavObj,
#     adjustPointTiers: bool = True,
#     adjustIntervalTiers: bool = True,
# ) -> textgrid.Textgrid:
# def splitAudioOnTier(
#     wavFN: str,
#     tgFN: str,
#     tierName: str,
#     outputPath: str,
#     outputTGFlag: bool = False,
#     nameStyle: Optional[Literal["append", "append_no_i", "label"]] = None,
#     noPartialIntervals: bool = False,
#     silenceLabel: str = None,
# ) -> List[Tuple[float, float, str]]:
#     def getValue(myBool) -> Literal["strict", "lax", "truncated"]:
# def alignBoundariesAcrossTiers(
#     tgFN: str, maxDifference: float = 0.01
# ) -> textgrid.Textgrid:
# def _findMisalignments(
#     tg: textgrid.Textgrid,
#     timeV: float,
#     maxDifference: float,
#     tierNameList: List[str],
#     tierName: str,
#     entry: list,
#     orderID: int,
# ) -> None:


import os
from os.path import join
from praatio import praatio_scripts
"""
Praatio example of extracting a separate wav file for each labeled entry in a textgrid tier
"""



path = join(".", "files")
outputPath = join(path, "sub_wavs")

if not os.path.exists(outputPath):
    os.mkdir(outputPath)

for wavFN, tgFN in [  # ("bobby.wav", "bobby_words.TextGrid"),
    ("mary.wav", "mary.TextGrid")
]:

# Path: praatio/praatio_scripts.py
# class NameStyle:
#     APPEND = "append"
#     APPEND_NO_I = "append_no_i"
#     LABEL = "label"
# def _shiftTimes(
#     tg: textgrid.Textgrid, timeV: float, newTimeV: float
# ) -> textgrid.Textgrid:
# def audioSplice(
#     audioObj: audio.WavObj,
#     spliceSegment: audio.WavObj,
#     tg: textgrid.Textgrid,
#     tierName: str,
#     newLabel: str,
#     insertStart: float,
#     insertStop: float = None,
#     alignToZeroCrossing: bool = True,
# ) -> Tuple[audio.WavObj, textgrid.Textgrid]:
# def spellCheckEntries(
#     tg: textgrid.Textgrid,
#     targetTierName: str,
#     newTierName: str,
#     checkFunction: Callable[[str], bool],
#     printEntries: bool = False,
# ) -> textgrid.Textgrid:
# def splitTierEntries(
#     tg: textgrid.Textgrid,
#     sourceTierName: str,
#     targetTierName: str,
#     startT: float = None,
#     endT: float = None,
# ) -> textgrid.Textgrid:
# def tgBoundariesToZeroCrossings(
#     tg: textgrid.Textgrid,
#     wavObj: audio.WavObj,
#     adjustPointTiers: bool = True,
#     adjustIntervalTiers: bool = True,
# ) -> textgrid.Textgrid:
# def splitAudioOnTier(
#     wavFN: str,
#     tgFN: str,
#     tierName: str,
#     outputPath: str,
#     outputTGFlag: bool = False,
#     nameStyle: Optional[Literal["append", "append_no_i", "label"]] = None,
#     noPartialIntervals: bool = False,
#     silenceLabel: str = None,
# ) -> List[Tuple[float, float, str]]:
#     def getValue(myBool) -> Literal["strict", "lax", "truncated"]:
# def alignBoundariesAcrossTiers(
#     tgFN: str, maxDifference: float = 0.01
# ) -> textgrid.Textgrid:
# def _findMisalignments(
#     tg: textgrid.Textgrid,
#     timeV: float,
#     maxDifference: float,
#     tierNameList: List[str],
#     tierName: str,
#     entry: list,
#     orderID: int,
# ) -> None:


# Path: examples/extract_subwavs.py
import os
from os.path import join
from praatio import praatio_scripts

"""
Praatio example of extracting a separate wav file for each labeled entry in a textgrid tier
"""



path = join(".", "files")
outputPath = join(path, "sub_wavs")

if not os.path.exists(outputPath):
    os.mkdir(outputPath)

for wavFN, tgFN in [  # ("bobby.wav", "bobby_words.TextGrid"),
    ("mary.wav", "mary.TextGrid")
]:

    praatio_scripts.splitAudioOnTier(