Update backend.py
Browse files- backend.py +7 -20
backend.py
CHANGED
|
@@ -191,27 +191,14 @@ def export_to_pdf(result: dict, filename="FinTalk_Report.pdf"):
|
|
| 191 |
|
| 192 |
|
| 193 |
def generate_tts_files(result):
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
print("⚠️ TTS modeli yüklenemedi:", e)
|
| 199 |
-
return
|
| 200 |
-
|
| 201 |
-
texts = {
|
| 202 |
-
"moderator_intro": result["moderator_intro"],
|
| 203 |
-
"bullish_view": result["bullish_view"],
|
| 204 |
-
"bearish_view": result["bearish_view"],
|
| 205 |
-
"moderator_wrap": result["moderator_wrap"]
|
| 206 |
-
}
|
| 207 |
-
|
| 208 |
-
for key, text in texts.items():
|
| 209 |
try:
|
| 210 |
print(f"🔊 {key} ses üretiliyor...")
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
sf.write(filename, audio, samplerate=16000)
|
| 215 |
-
print(f"✅ {filename} oluşturuldu (transformers offline)")
|
| 216 |
except Exception as e:
|
| 217 |
print(f"TTS hatası ({key}):", e)
|
|
|
|
| 191 |
|
| 192 |
|
| 193 |
def generate_tts_files(result):
|
| 194 |
+
print("🎙️ Offline TTS (espnet VITS) başlatıldı...")
|
| 195 |
+
pipe = pipeline("text-to-speech", model="espnet/kan-bayashi_ljspeech_vits")
|
| 196 |
+
keys = ["moderator_intro","bullish_view","bearish_view","moderator_wrap"]
|
| 197 |
+
for key in keys:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
try:
|
| 199 |
print(f"🔊 {key} ses üretiliyor...")
|
| 200 |
+
out = pipe(result[key])
|
| 201 |
+
sf.write(f"{key}.wav", out["audio"], 22050)
|
| 202 |
+
print(f"✅ {key}.wav oluşturuldu (offline VITS)")
|
|
|
|
|
|
|
| 203 |
except Exception as e:
|
| 204 |
print(f"TTS hatası ({key}):", e)
|