from sphfile import SPHFile
import os
def get_wave_path(wav_path):
wave_files = []
for (dirpath, dirname, filenames) in os.walk(wav_path):
for filename in filenames:
if filename.endswith('.wav') or filename.endswith('.WAV'):
filename_path = os.path.join(dirpath, filename)
if filename_path.split('/')[-2]=='.ipynb_checkpoints':
continue
wave_files.append(filename_path)
return wave_files
def sphfile_trans_to_wave(wave_file):
for wav in wave_file:
file = SPHFile(wav)
print(wav)
print(wave_file)
wav_new = "/home/tione/notebook/asr_data/new_"+wav.split('/')[-1]
file.write_wav(filename=wav_new)
wave_path = '/home/tione/notebook/asr_data'
wave_file = get_wave_path(wave_path)
sphfile_trans_to_wave(wave_file)