Add a simple text to speech example
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
*.pyc
|
||||
*.pyc
|
||||
venv/
|
||||
text_to_speech/models
|
||||
@@ -29,9 +29,6 @@ def translator_de_fr(query):
|
||||
return translate(MODEL, syspromts.TRANSLATOR_DE_FR + query)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
response = translator_de_en(test_content.TESTSENTENCE_DE_BROKER)
|
||||
print(json.dumps(response, indent=2))
|
||||
|
||||
6
readme.md
Normal file
6
readme.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# Prerequisites
|
||||
|
||||
sudo apt install liblc3-tools
|
||||
|
||||
use python3.9
|
||||
pip install piper-tts soundfile librosa
|
||||
6
text_to_speech/piper_welcome.sh
Normal file
6
text_to_speech/piper_welcome.sh
Normal file
@@ -0,0 +1,6 @@
|
||||
SCRIPT_DIR=$(dirname "$(readlink -f "$BASH_SOURCE")")
|
||||
|
||||
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
|
||||
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()
|
||||
0
text_to_speech/text_to_speech.py
Normal file
0
text_to_speech/text_to_speech.py
Normal file
Reference in New Issue
Block a user