Update tts.py
Browse files
tts.py
CHANGED
@@ -23,12 +23,18 @@ def synthesize_speech(text):
|
|
23 |
return None
|
24 |
|
25 |
result = pipe(text)
|
26 |
-
|
27 |
|
28 |
-
#
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
except Exception as e:
|
33 |
logging.error(f"Error during speech synthesis: {e}")
|
34 |
return None
|
|
|
23 |
return None
|
24 |
|
25 |
result = pipe(text)
|
26 |
+
logging.debug(f"Pipeline result: {result}")
|
27 |
|
28 |
+
# Check if the output contains 'waveform' key
|
29 |
+
if 'waveform' in result:
|
30 |
+
waveform = result['waveform']
|
31 |
+
# Save waveform to an audio file
|
32 |
+
audio_path = "output.wav"
|
33 |
+
sf.write(audio_path, waveform, 16000) # Write the waveform using soundfile
|
34 |
+
return audio_path
|
35 |
+
else:
|
36 |
+
logging.error(f"Unexpected pipeline output: {result}")
|
37 |
+
return None
|
38 |
except Exception as e:
|
39 |
logging.error(f"Error during speech synthesis: {e}")
|
40 |
return None
|