# use liblc3
import os
import subprocess

frame_dur_ms=10
srate=16000
bps=32000

if __name__ == '__main__':
    workdir = os.path.dirname(__file__)
    os.chdir(workdir)
    files = os.listdir(workdir)
    filtered = [file for file in files if file.endswith('.wav')]

    for file in filtered:
        cmd = [
            'elc3', 
            '-b', f'{bps}',
            '-m', f'{frame_dur_ms}' , 
            '-r', f'{srate}',
            f'{file}', f'{file.replace('.wav', '')}_{frame_dur_ms}_{srate//1000}_{bps//1000}.lc3'
            ]
        print("Executing: ", " ".join(cmd))
        ret = subprocess.run(cmd, check=True)
        print(ret.returncode, ret.stdout, ret.stderr)
