nsultan5 commited on
Commit
81904b6
·
verified ·
1 Parent(s): 74c738a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -18,15 +18,19 @@ import pyttsx3
18
  import tempfile
19
 
20
  # --------------------------
21
- # Text-to-Speech Setup
 
22
  # --------------------------
23
- engine = pyttsx3.init()
 
 
24
 
25
  def speak_text_to_audio(text):
26
- with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as fp:
27
- engine.save_to_file(text, fp.name)
28
- engine.runAndWait()
29
- return fp.name # Gradio Audio uses this path
 
30
 
31
  # --------------------------
32
  # Load Quantized LLaMA 2 via AutoGPTQ
 
18
  import tempfile
19
 
20
  # --------------------------
21
+
22
+ # Text-to-Speech Setup (gTTS version)
23
  # --------------------------
24
+ from gtts import gTTS
25
+ import tempfile
26
+ import os
27
 
28
  def speak_text_to_audio(text):
29
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as fp:
30
+ tts = gTTS(text=text, lang='en')
31
+ tts.save(fp.name)
32
+ return fp.name # Gradio Audio can use this path
33
+
34
 
35
  # --------------------------
36
  # Load Quantized LLaMA 2 via AutoGPTQ