19 lines
572 B
Python
19 lines
572 B
Python
# resample .wave from 22.05 to 24kHz sampling rate
|
|
|
|
import librosa
|
|
import soundfile as sf
|
|
|
|
|
|
def resample(filename, out_filename, target_rate=int(24e3)):
|
|
# Load the original audio file
|
|
audio, rate = librosa.load(filename)
|
|
|
|
# Convert the sample rate to 24 kHz
|
|
resampled_audio = librosa.resample(audio, orig_sr=rate, target_sr=target_rate)
|
|
|
|
# Save the resampled audio as a new .wav file
|
|
sf.write(out_filename, resampled_audio, target_rate)
|
|
|
|
if __name__ == "__main__":
|
|
resample('text_to_speech/welcome.wav', 'text_to_speech/welcome_resampled.wav')
|