Update tts.py
Browse files
tts.py
CHANGED
@@ -25,12 +25,13 @@ def synthesize_speech(text):
|
|
25 |
result = pipe(text)
|
26 |
logging.debug(f"Pipeline result: {result}")
|
27 |
|
28 |
-
# Check if the output contains '
|
29 |
-
if '
|
30 |
-
|
31 |
-
|
|
|
32 |
audio_path = "output.wav"
|
33 |
-
sf.write(audio_path,
|
34 |
return audio_path
|
35 |
else:
|
36 |
logging.error(f"Unexpected pipeline output: {result}")
|
|
|
25 |
result = pipe(text)
|
26 |
logging.debug(f"Pipeline result: {result}")
|
27 |
|
28 |
+
# Check if the output contains 'audio' and 'sampling_rate' keys
|
29 |
+
if 'audio' in result and 'sampling_rate' in result:
|
30 |
+
audio = result['audio']
|
31 |
+
sampling_rate = result['sampling_rate']
|
32 |
+
# Save audio to an audio file
|
33 |
audio_path = "output.wav"
|
34 |
+
sf.write(audio_path, audio[0], sampling_rate) # Write the audio using soundfile
|
35 |
return audio_path
|
36 |
else:
|
37 |
logging.error(f"Unexpected pipeline output: {result}")
|