# 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: praatio/data_points.py
# def open1DPointObject(fn: str) -> PointObject1D:
# def open2DPointObject(fn: str) -> PointObject2D:
# def _parseNormalHeader(fn: str) -> Tuple[str, str, float, float]:
# def _getNextValue(data: str, start: int) -> Tuple[str, int]:
# def _parseShortHeader(fn: str) -> Tuple[str, str, float, float]:
# 
# Path: praatio/utilities/constants.py
# INTERVAL_TIER: Final = "IntervalTier"
# POINT_TIER: Final = "TextTier"
# MIN_INTERVAL_LENGTH: Final = 0.00000001  # Arbitrary threshold
#     LONG_TEXTGRID: Final = "long_textgrid"
#     SHORT_TEXTGRID: Final = "short_textgrid"
#     JSON: Final = "json"
#     POINT: Final = "PointProcess"
#     PITCH: Final = "PitchTier"
#     DURATION: Final = "DurationTier"
#     STRICT: Final = "strict"
#     LAX: Final = "lax"
#     TRUNCATED: Final = "truncated"
#     SILENCE: Final = "silence"
#     WARNING: Final = "warning"
#     ERROR: Final = "error"
#     REPLACE: Final = "replace"
#     MERGE: Final = "merge"
#     ERROR: Final = "error"
#     STRETCH: Final = "stretch"
#     SPLIT: Final = "split"
#     NO_CHANGE: Final = "no_change"
#     ERROR: Final = "error"
#     TRUNCATE: Final = "truncate"
#     CATEGORICAL: Final = "categorical"
#     ERROR: Final = "error"
#     ERROR: Final = "error"
#     RENAME: Final = "rename"
# class Interval(namedtuple("Interval", ["start", "end", "label"])):
# class Point(namedtuple("Point", ["time", "label"])):
# class TextgridFormats:
# class DataPointTypes:
# class CropCollision:
# class ErrorReportingMode:
# class IntervalCollision:
# class WhitespaceCollision:
# class EraseCollision:
# class DuplicateNames:
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):


import os
from os.path import join
from praatio import textgrid
from praatio import data_points
from praatio.utilities import constants
"""
Praatio example for extracting points in a PointProcess for the vowels specified in a textgrid
"""



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

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

tg = textgrid.openTextgrid(join(path, "bobby_phones.TextGrid"), False)
pp = data_points.open1DPointObject(join(path, "bobby.PointProcess"))

newPoints = []
tier = tg.tierDict["phone"]
for interval in tier.entryList:
    if interval.label.lower()[0] not in ["a", "e", "i", "o", "u"]:
        continue
    for val in pp.getPointsInInterval(interval.start, interval.end):
        newPoints.append((val,))


# 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: praatio/data_points.py
# def open1DPointObject(fn: str) -> PointObject1D:
# def open2DPointObject(fn: str) -> PointObject2D:
# def _parseNormalHeader(fn: str) -> Tuple[str, str, float, float]:
# def _getNextValue(data: str, start: int) -> Tuple[str, int]:
# def _parseShortHeader(fn: str) -> Tuple[str, str, float, float]:
# 
# Path: praatio/utilities/constants.py
# INTERVAL_TIER: Final = "IntervalTier"
# POINT_TIER: Final = "TextTier"
# MIN_INTERVAL_LENGTH: Final = 0.00000001  # Arbitrary threshold
#     LONG_TEXTGRID: Final = "long_textgrid"
#     SHORT_TEXTGRID: Final = "short_textgrid"
#     JSON: Final = "json"
#     POINT: Final = "PointProcess"
#     PITCH: Final = "PitchTier"
#     DURATION: Final = "DurationTier"
#     STRICT: Final = "strict"
#     LAX: Final = "lax"
#     TRUNCATED: Final = "truncated"
#     SILENCE: Final = "silence"
#     WARNING: Final = "warning"
#     ERROR: Final = "error"
#     REPLACE: Final = "replace"
#     MERGE: Final = "merge"
#     ERROR: Final = "error"
#     STRETCH: Final = "stretch"
#     SPLIT: Final = "split"
#     NO_CHANGE: Final = "no_change"
#     ERROR: Final = "error"
#     TRUNCATE: Final = "truncate"
#     CATEGORICAL: Final = "categorical"
#     ERROR: Final = "error"
#     ERROR: Final = "error"
#     RENAME: Final = "rename"
# class Interval(namedtuple("Interval", ["start", "end", "label"])):
# class Point(namedtuple("Point", ["time", "label"])):
# class TextgridFormats:
# class DataPointTypes:
# class CropCollision:
# class ErrorReportingMode:
# class IntervalCollision:
# class WhitespaceCollision:
# class EraseCollision:
# class DuplicateNames:
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):


# Path: examples/get_vowel_points.py
import os
from os.path import join
from praatio import textgrid
from praatio import data_points
from praatio.utilities import constants

"""
Praatio example for extracting points in a PointProcess for the vowels specified in a textgrid
"""



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

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

tg = textgrid.openTextgrid(join(path, "bobby_phones.TextGrid"), False)
pp = data_points.open1DPointObject(join(path, "bobby.PointProcess"))

newPoints = []
tier = tg.tierDict["phone"]
for interval in tier.entryList:
    if interval.label.lower()[0] not in ["a", "e", "i", "o", "u"]:
        continue
    for val in pp.getPointsInInterval(interval.start, interval.end):
        newPoints.append((val,))


outputPP = data_points.PointObject1D(