sreepathi-ravikumar commited on
Commit
b5cc186
·
verified ·
1 Parent(s): c8237bf

Update AudioGeneration.py

Browse files
Files changed (1) hide show
  1. AudioGeneration.py +6 -5
AudioGeneration.py CHANGED
@@ -1,9 +1,10 @@
1
  from TTS.api import TTS
 
2
 
3
- # Load the model once
4
- tts_model = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False, gpu=False)
5
 
6
- def generate_audio(text, filename):
7
- output_path = filename
8
- tts_model.tts_to_file(text=text, file_path=output_path)
9
  return output_path
 
1
  from TTS.api import TTS
2
+ import os
3
 
4
+ # Initialize the TTS model (use a lightweight but high-quality model)
5
+ tts = TTS(model_name="tts_models/en/ljspeech/tacotron2-DDC", progress_bar=False, gpu=False)
6
 
7
+ def generate_audio(text):
8
+ output_path = "output.wav"
9
+ tts.tts_to_file(text=text, file_path=output_path)
10
  return output_path