Add a simple text to speech example
This commit is contained in:
19
text_to_speech/resample.py
Normal file
19
text_to_speech/resample.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# resample .wave from 22.05 to 24kHz sampling rate
|
||||
|
||||
import librosa
|
||||
import soundfile as sf
|
||||
|
||||
|
||||
def resample():
|
||||
# Load the original audio file
|
||||
audio, rate = librosa.load('welcome.wav')
|
||||
|
||||
# Convert the sample rate to 24 kHz
|
||||
resampled_rate = int(rate * 24 / 22050)
|
||||
resampled_audio = librosa.resample(audio, rate, resampled_rate)
|
||||
|
||||
# Save the resampled audio as a new .wav file
|
||||
sf.write('welcome_resampled.wav', resampled_audio, resampled_rate)
|
||||
|
||||
if __name__ == "__main__":
|
||||
resample()
|
||||
Reference in New Issue
Block a user