Spaces:
Sleeping
Sleeping
#!/usr/bin/python3 | |
# -*- coding: utf-8 -*- | |
import librosa | |
import numpy as np | |
from scipy.io import wavfile | |
def audio_convert(in_filename: str, | |
out_filename: str, | |
sample_rate: int = 16000): | |
signal, _ = librosa.load(in_filename, sr=sample_rate) | |
signal *= 32768.0 | |
signal = np.array(signal, dtype=np.int16) | |
wavfile.write( | |
out_filename, | |
rate=sample_rate, | |
data=signal | |
) | |
return out_filename | |
if __name__ == "__main__": | |
pass | |