# Path: praatio/utilities/errors.py
# class PraatioException(Exception):
# class SafeZipException(PraatioException):
# class FileNotFound(PraatioException):
# class ParsingError(PraatioException):
# class ArgumentError(PraatioException):
# class UnexpectedError(PraatioException):
# class WrongOption(PraatioException):
# class TextgridException(PraatioException):
# class DuplicateTierName(TextgridException):
# class OutOfBounds(TextgridException):
# class CollisionError(TextgridException):
# class TimelessTextgridTierException(TextgridException):
# class TextgridStateAutoModified(TextgridException):
# class TextgridStateError(TextgridException):
# class TierNameExistsError(TextgridException):
# class IncompatibleTierError(TextgridException):
# class PraatExecutionFailed(PraatioException):
# class EndOfAudioData(PraatioException):
# class FindZeroCrossingError(PraatioException):
# class NormalizationException(PraatioException):
#     def __init__(self, fullPath: str):
#     def __str__(self):
#     def __init__(self, argumentName: str, givenValue: str, availableOptions: List[str]):
#     def __str__(self):
#     def __str__(self):
#     def __init__(self, tier):
#     def __str__(self):
#     def __init__(self, cmdList: List[str]):
#     def __str__(self):
#     def __init__(self, startTime: float, endTime: float):
#     def __str__(self):
#     def __str__(self):


import math
import statistics
from typing import Callable, List, Tuple
from praatio.utilities import errors

def znormalizeSpeakerData(
    featureTimeList: List[Tuple[float, ...]], index: int, filterZeroValues: bool
) -> List[Tuple[float, ...]]:
    """
    znormalize time series data

    The idea is to normalize each speaker separately to be able
    to compare data across several speakers for speaker-dependent
    data like pitch range

    To normalize a speakers data within a local window, use filterTimeSeriesData()

    filterZeroValues: if True, don't consider zero values in the mean and stdDev
      (recommended value for data like pitch or intensity)
    """
    featValues = [row[index] for row in featureTimeList]

    if not filterZeroValues:
        featValues = znormalizeData(featValues)
    else:
        featValuesNoZeroes = [val for val in featValues if val != ""]
        meanVal = statistics.mean(featValuesNoZeroes)
        stdDevVal = statistics.stdev(featValuesNoZeroes)

        featValues = [
            (val - meanVal) / stdDevVal if val > 0 else 0 for val in featValues
        ]

    if len(featureTimeList) != len(featValues):

# Path: praatio/utilities/errors.py
# class PraatioException(Exception):
# class SafeZipException(PraatioException):
# class FileNotFound(PraatioException):
# class ParsingError(PraatioException):
# class ArgumentError(PraatioException):
# class UnexpectedError(PraatioException):
# class WrongOption(PraatioException):
# class TextgridException(PraatioException):
# class DuplicateTierName(TextgridException):
# class OutOfBounds(TextgridException):
# class CollisionError(TextgridException):
# class TimelessTextgridTierException(TextgridException):
# class TextgridStateAutoModified(TextgridException):
# class TextgridStateError(TextgridException):
# class TierNameExistsError(TextgridException):
# class IncompatibleTierError(TextgridException):
# class PraatExecutionFailed(PraatioException):
# class EndOfAudioData(PraatioException):
# class FindZeroCrossingError(PraatioException):
# class NormalizationException(PraatioException):
#     def __init__(self, fullPath: str):
#     def __str__(self):
#     def __init__(self, argumentName: str, givenValue: str, availableOptions: List[str]):
#     def __str__(self):
#     def __str__(self):
#     def __init__(self, tier):
#     def __str__(self):
#     def __init__(self, cmdList: List[str]):
#     def __str__(self):
#     def __init__(self, startTime: float, endTime: float):
#     def __str__(self):
#     def __str__(self):


# Path: praatio/utilities/my_math.py
import math
import statistics
from typing import Callable, List, Tuple
from praatio.utilities import errors


def znormalizeSpeakerData(
    featureTimeList: List[Tuple[float, ...]], index: int, filterZeroValues: bool
) -> List[Tuple[float, ...]]:
    """
    znormalize time series data

    The idea is to normalize each speaker separately to be able
    to compare data across several speakers for speaker-dependent
    data like pitch range

    To normalize a speakers data within a local window, use filterTimeSeriesData()

    filterZeroValues: if True, don't consider zero values in the mean and stdDev
      (recommended value for data like pitch or intensity)
    """
    featValues = [row[index] for row in featureTimeList]

    if not filterZeroValues:
        featValues = znormalizeData(featValues)
    else:
        featValuesNoZeroes = [val for val in featValues if val != ""]
        meanVal = statistics.mean(featValuesNoZeroes)
        stdDevVal = statistics.stdev(featValuesNoZeroes)

        featValues = [
            (val - meanVal) / stdDevVal if val > 0 else 0 for val in featValues
        ]

    if len(featureTimeList) != len(featValues):

        errors.ArgumentError(