Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ from TTS.tts.configs.xtts_config import XttsConfig
|
|
15 |
from TTS.tts.models.xtts import Xtts
|
16 |
from vinorm import TTSnorm
|
17 |
from content_generation import create_content # Nhập hàm create_content từ file content_generation.py
|
|
|
18 |
from PIL import Image
|
19 |
from pathlib import Path
|
20 |
import requests
|
@@ -250,6 +251,12 @@ def predict(
|
|
250 |
generated_text = create_content(prompt, content_type, language)
|
251 |
print(f"Generated text: {generated_text}")
|
252 |
prompt = generated_text
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
if language not in supported_languages:
|
254 |
metrics_text = gr.Warning(
|
255 |
f"Language you put {language} in is not in our Supported Languages, please choose from dropdown"
|
@@ -399,7 +406,7 @@ with gr.Blocks(analytics_enabled=False) as demo:
|
|
399 |
)
|
400 |
content_type_dropdown = gr.Dropdown(
|
401 |
label="Loại nội dung",
|
402 |
-
choices=["triết lý sống", "Theo yêu cầu"],
|
403 |
value="Theo yêu cầu",
|
404 |
)
|
405 |
ref_gr = gr.Audio(
|
|
|
15 |
from TTS.tts.models.xtts import Xtts
|
16 |
from vinorm import TTSnorm
|
17 |
from content_generation import create_content # Nhập hàm create_content từ file content_generation.py
|
18 |
+
from sports_news import get_sports_news_content # Nhập hàm lấy tin thể thao
|
19 |
from PIL import Image
|
20 |
from pathlib import Path
|
21 |
import requests
|
|
|
251 |
generated_text = create_content(prompt, content_type, language)
|
252 |
print(f"Generated text: {generated_text}")
|
253 |
prompt = generated_text
|
254 |
+
elif content_type in ["tin thể thao", "tin bóng đá"]:
|
255 |
+
print("I: Fetching sports news...")
|
256 |
+
news_type = "football" if content_type == "tin bóng đá" else "all"
|
257 |
+
sports_content = get_sports_news_content(news_type, language, 5)
|
258 |
+
print(f"Sports content: {sports_content}")
|
259 |
+
prompt = sports_content
|
260 |
if language not in supported_languages:
|
261 |
metrics_text = gr.Warning(
|
262 |
f"Language you put {language} in is not in our Supported Languages, please choose from dropdown"
|
|
|
406 |
)
|
407 |
content_type_dropdown = gr.Dropdown(
|
408 |
label="Loại nội dung",
|
409 |
+
choices=["triết lý sống", "Theo yêu cầu", "tin thể thao", "tin bóng đá"],
|
410 |
value="Theo yêu cầu",
|
411 |
)
|
412 |
ref_gr = gr.Audio(
|