Spaces:
Runtime error
Runtime error
Update Infer.py
Browse files
Infer.py
CHANGED
@@ -1,21 +1,18 @@
|
|
1 |
import tensorflow as tf
|
|
|
2 |
import numpy as np
|
3 |
import soundfile as sf
|
4 |
-
import os
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
SAMPLE_RATE = 22050
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
model = tf.keras.models.load_model(MODEL_PATH)
|
13 |
-
audio = model.predict(x_input)[0]
|
14 |
-
os.makedirs("output", exist_ok=True)
|
15 |
-
output_path = "output/generated.wav"
|
16 |
-
sf.write(output_path, audio, SAMPLE_RATE)
|
17 |
-
print(f"Generated speech saved at: {output_path}")
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
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'")
|