Update tts.py
Browse files
tts.py
CHANGED
@@ -33,9 +33,10 @@ def synthesize_speech(text):
|
|
33 |
# Decode the generated speech and save to an audio file
|
34 |
waveform = speech.cpu().numpy().flatten()
|
35 |
# Use torchaudio to save the waveform
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
39 |
except Exception as e:
|
40 |
logging.error(f"Error during speech synthesis: {e}")
|
41 |
return None
|
|
|
33 |
# Decode the generated speech and save to an audio file
|
34 |
waveform = speech.cpu().numpy().flatten()
|
35 |
# Use torchaudio to save the waveform
|
36 |
+
file_path = "output.wav"
|
37 |
+
torchaudio.save(file_path, torch.tensor(waveform).unsqueeze(0), 16000)
|
38 |
+
logging.info(f"Audio file saved successfully at {file_path}.")
|
39 |
+
return file_path
|
40 |
except Exception as e:
|
41 |
logging.error(f"Error during speech synthesis: {e}")
|
42 |
return None
|