import sys
import os
from ..praat import run_script, read_praat_out

from ..helper import ASTemporaryDirectory, fix_time_points


def file_to_pitch_praat(file_path, praat_path=None, time_step=0.01, min_pitch=75, max_pitch=600):
    script_dir = os.path.dirname(os.path.abspath(__file__))
    script = os.path.join(script_dir, 'pitch.praat')
    if praat_path is None:
        praat_path = 'praat'
        if sys.platform == 'win32':
            praat_path += 'con.exe'
    listing = run_script(praat_path, script, file_path, time_step, min_pitch, max_pitch)
    output = read_praat_out(listing)
    return output


def signal_to_pitch_praat(signal, sr, praat_path=None,
                          time_step=0.01, min_pitch=75, max_pitch=600, begin=None, padding=None):
    with ASTemporaryDirectory(prefix = 'acousticsim') as tempdir:
        t_wav = tempdir.create_temp_file(signal, sr)
        output = file_to_pitch_praat(t_wav.name, praat_path, time_step, min_pitch, max_pitch)
    duration = signal.shape[0] / sr
    return fix_time_points(output, begin, padding, duration)
@@ -87,45 +87,43 @@
 ort 
-ASTemporaryDirectory, fix_time_points
+fix_time_points, ASTemporaryWavFile
 %0A%0A%0Ad
@@ -783,91 +783,12 @@
 rary
-Directory(prefix = 'acousticsim') as tempdir:%0A        t_wav = tempdir.create_temp_f
+WavF
 ile(
@@ -798,16 +798,29 @@
 nal, sr)
+ as wav_path:
 %0A       
@@ -853,18 +853,16 @@
 aat(
-t_
 wav
-.name
+_path
 , pr

Fix praat pitch