Files
auracast-translator/text_to_speech/resample.py

18 lines
525 B
Python

# resample .wave from 22.05 to 24kHz sampling rate
import librosa
import soundfile as sf
def resample(target_rate=int(24e3)):
# Load the original audio file
audio, rate = librosa.load('text_to_speech/welcome.wav')
# 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('text_to_speech/welcome_resampled.wav', resampled_audio, target_rate)
if __name__ == "__main__":
resample()