def apply_formant_and_pitch_shift(
    sound: parselmouth.Sound,
    formant_shift_ratio: float = PRAAT_CHANGEGENDER_FORMANTSHIFTRATIO_DEFAULT,
    pitch_shift_ratio: float = PRAAT_CHANGEGENDER_PITCHSHIFTRATIO_DEFAULT,
    pitch_range_ratio: float = PRAAT_CHANGEGENDER_PITCHRANGERATIO_DEFAULT,
    duration_factor: float = PRAAT_CHANGEGENDER_DURATIONFACTOR_DEFAULT,
) -> parselmouth.Sound:
    """use Praat "Changer gender" command to manipulate pitch and formant
    "Change gender": Praat -> Sound Object -> Convert -> Change gender
    refer to Help of Praat for more details
    # https://github.com/YannickJadoul/Parselmouth/issues/25#issuecomment-608632887 might help
    """
    pitch = None
    new_pitch_median = PRAAT_CHANGEGENDER_PITCHMEDIAN_DEFAULT
    if pitch_shift_ratio != 1.0:
        pitch, pitch_median = get_pitch_median(sound, sound.sampling_frequency)
        new_pitch_median = pitch_median * pitch_shift_ratio

        # refer to https://github.com/praat/praat/issues/1926#issuecomment-974909408
        pitch_minimum = parselmouth.praat.call(
            pitch, "Get minimum", 0.0, 0.0, "Hertz", "Parabolic"
        )
        new_median = pitch_median * pitch_shift_ratio
        scaled_minimum = pitch_minimum * pitch_shift_ratio
        result_minimum = new_median + (scaled_minimum - new_median) * pitch_range_ratio
        if result_minimum < 0:
            new_pitch_median = PRAAT_CHANGEGENDER_PITCHMEDIAN_DEFAULT
            pitch_range_ratio = PRAAT_CHANGEGENDER_PITCHRANGERATIO_DEFAULT

        if math.isnan(new_pitch_median):
            new_pitch_median = PRAAT_CHANGEGENDER_PITCHMEDIAN_DEFAULT
            pitch_range_ratio = PRAAT_CHANGEGENDER_PITCHRANGERATIO_DEFAULT

    new_sound = change_gender(
        sound,
        pitch,
        formant_shift_ratio,
        new_pitch_median,
        pitch_range_ratio,
        duration_factor,
    )
    return new_sound
use Praat "Changer gender" command to manipulate pitch and formant
"Change gender": Praat -> Sound Object -> Convert -> Change gender
refer to Help of Praat for more details
# https://github.com/YannickJadoul/Parselmouth/issues/25#issuecomment-608632887 might help
processors/data_augment.py