Create infer.py
Browse files
infer.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tensorflow as tf
|
| 2 |
+
import librosa
|
| 3 |
+
import numpy as np
|
| 4 |
+
import soundfile as sf
|
| 5 |
+
|
| 6 |
+
# Load the trained model
|
| 7 |
+
model = tf.keras.models.load_model('model/clone_tts_model.h5')
|
| 8 |
+
|
| 9 |
+
# Define input text
|
| 10 |
+
text_input = "Hello, welcome to CloneTTS. This is an example of text-to-speech synthesis."
|
| 11 |
+
|
| 12 |
+
# Generate the speech (preprocess as needed depending on model requirements)
|
| 13 |
+
speech = model.predict(np.array([text_input]))
|
| 14 |
+
|
| 15 |
+
# Save the generated speech to a .wav file
|
| 16 |
+
sf.write('output/speech.wav', speech, 22050) # Adjust sample rate as necessary
|
| 17 |
+
|
| 18 |
+
print("Speech generated and saved as 'output/speech.wav'")
|