Add piper hello world example with resample to 24kHz
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "$BASH_SOURCE")")
|
||||
START_DIR=$(pwd)
|
||||
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
echo 'Welcome to the world of speech synthesis!' | piper \
|
||||
--model en_US-lessac-medium \
|
||||
--output_file $SCRIPT_DIR/welcome.wav \
|
||||
--download-dir $SCRIPT_DIR/models
|
||||
#--download-dir $SCRIPT_DIR/models \
|
||||
#--data-dir $SCRIPT_DIR/models
|
||||
|
||||
|
||||
cd $START_DIR
|
||||
@@ -4,16 +4,15 @@ import librosa
|
||||
import soundfile as sf
|
||||
|
||||
|
||||
def resample():
|
||||
def resample(target_rate=int(24e3)):
|
||||
# Load the original audio file
|
||||
audio, rate = librosa.load('welcome.wav')
|
||||
audio, rate = librosa.load('text_to_speech/welcome.wav')
|
||||
|
||||
# Convert the sample rate to 24 kHz
|
||||
resampled_rate = int(rate * 24 / 22050)
|
||||
resampled_audio = librosa.resample(audio, rate, resampled_rate)
|
||||
resampled_audio = librosa.resample(audio, orig_sr=rate, target_sr=target_rate)
|
||||
|
||||
# Save the resampled audio as a new .wav file
|
||||
sf.write('welcome_resampled.wav', resampled_audio, resampled_rate)
|
||||
sf.write('text_to_speech/welcome_resampled.wav', resampled_audio, target_rate)
|
||||
|
||||
if __name__ == "__main__":
|
||||
resample()
|
||||
6353
text_to_speech/voices.json
Normal file
6353
text_to_speech/voices.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user