# Path: opensauce/snack.py
# def snack_pitch(wav_fn, method, data_len, frame_shift=1,
#                 window_size=25, max_pitch=500, min_pitch=40,
#                 tcl_shell_cmd=None):
# def snack_raw_pitch(wav_fn, method, frame_shift=1, window_size=25,
#                     max_pitch=500, min_pitch=40, tcl_shell_cmd=None):
# def snack_raw_pitch_exe(wav_fn, frame_shift, window_size, max_pitch, min_pitch): # pragma: no cover
# def snack_raw_pitch_python(wav_fn, frame_shift, window_size, max_pitch, min_pitch):
# def snack_raw_pitch_tcl(wav_fn, frame_shift, window_size, max_pitch, min_pitch, tcl_shell_cmd):
# def snack_formants(wav_fn, method, data_len, frame_shift=1,
#                    window_size=25, pre_emphasis=0.96, lpc_order=12,
#                    tcl_shell_cmd=None):
# def snack_raw_formants(wav_fn, method, frame_shift=1, window_size=25,
#                        pre_emphasis=0.96, lpc_order=12, tcl_shell_cmd=None):
# def snack_raw_formants_exe(wav_fn, frame_shift, window_size, pre_emphasis, lpc_order): # pragma: no cover
# def snack_raw_formants_python(wav_fn, frame_shift, window_size, pre_emphasis, lpc_order):
# def snack_raw_formants_tcl(wav_fn, frame_shift, window_size, pre_emphasis, lpc_order, tcl_shell_cmd):


import sys
import os
import glob
import numpy as np
import matplotlib.pyplot as plt
from opensauce.snack import snack_raw_formants, sformant_names
# Script to compare Snack formant methods on Windows
# There is a known discrepancy between Snack formants calculated using
# the full Snack Tcl library ('tcl' method) and the Windows standalone
# executable ('exe' method)

# Licensed under Apache v2 (see LICENSE)




wav_dir = 'test/data/sound-files'
# Find all .wav files in test/data directory
wav_files = glob.glob(os.path.join(wav_dir, '*.wav'))

for wav_file in wav_files:
    print('Processing wav file {}'.format(wav_file))
    # Generate raw Snack formant samples
    # Use VoiceSauce default parameter values
    estimates_raw_tcl = snack_raw_formants(wav_file, 'tcl', frame_shift=1, window_size=25, pre_emphasis=0.96, lpc_order=12, tcl_shell_cmd = 'tclsh')
    estimates_raw_exe = snack_raw_formants(wav_file, 'exe', frame_shift=1, window_size=25, pre_emphasis=0.96, lpc_order=12)

    fig = plt.figure(figsize=(8,8))
    fig.suptitle('Snack formants - ' + os.path.basename(wav_file))

# Path: opensauce/snack.py
# def snack_pitch(wav_fn, method, data_len, frame_shift=1,
#                 window_size=25, max_pitch=500, min_pitch=40,
#                 tcl_shell_cmd=None):
# def snack_raw_pitch(wav_fn, method, frame_shift=1, window_size=25,
#                     max_pitch=500, min_pitch=40, tcl_shell_cmd=None):
# def snack_raw_pitch_exe(wav_fn, frame_shift, window_size, max_pitch, min_pitch): # pragma: no cover
# def snack_raw_pitch_python(wav_fn, frame_shift, window_size, max_pitch, min_pitch):
# def snack_raw_pitch_tcl(wav_fn, frame_shift, window_size, max_pitch, min_pitch, tcl_shell_cmd):
# def snack_formants(wav_fn, method, data_len, frame_shift=1,
#                    window_size=25, pre_emphasis=0.96, lpc_order=12,
#                    tcl_shell_cmd=None):
# def snack_raw_formants(wav_fn, method, frame_shift=1, window_size=25,
#                        pre_emphasis=0.96, lpc_order=12, tcl_shell_cmd=None):
# def snack_raw_formants_exe(wav_fn, frame_shift, window_size, pre_emphasis, lpc_order): # pragma: no cover
# def snack_raw_formants_python(wav_fn, frame_shift, window_size, pre_emphasis, lpc_order):
# def snack_raw_formants_tcl(wav_fn, frame_shift, window_size, pre_emphasis, lpc_order, tcl_shell_cmd):


# Path: tools/compare_snack_formants.py
import sys
import os
import glob
import numpy as np
import matplotlib.pyplot as plt
from opensauce.snack import snack_raw_formants, sformant_names

# Script to compare Snack formant methods on Windows
# There is a known discrepancy between Snack formants calculated using
# the full Snack Tcl library ('tcl' method) and the Windows standalone
# executable ('exe' method)

# Licensed under Apache v2 (see LICENSE)




wav_dir = 'test/data/sound-files'
# Find all .wav files in test/data directory
wav_files = glob.glob(os.path.join(wav_dir, '*.wav'))

for wav_file in wav_files:
    print('Processing wav file {}'.format(wav_file))
    # Generate raw Snack formant samples
    # Use VoiceSauce default parameter values
    estimates_raw_tcl = snack_raw_formants(wav_file, 'tcl', frame_shift=1, window_size=25, pre_emphasis=0.96, lpc_order=12, tcl_shell_cmd = 'tclsh')
    estimates_raw_exe = snack_raw_formants(wav_file, 'exe', frame_shift=1, window_size=25, pre_emphasis=0.96, lpc_order=12)

    fig = plt.figure(figsize=(8,8))
    fig.suptitle('Snack formants - ' + os.path.basename(wav_file))

    for i, n in enumerate(sformant_names):