Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
from langchain.chains import LLMChain
|
3 |
from langchain.prompts import PromptTemplate
|
4 |
-
from
|
5 |
from transformers import pipeline
|
6 |
from bs4 import BeautifulSoup
|
7 |
import requests
|
8 |
from TTS.api import TTS
|
9 |
import tempfile
|
10 |
import os
|
11 |
-
import shutil
|
12 |
|
13 |
# Setup summarization LLM
|
14 |
summary_pipe = pipeline("text2text-generation", model="google/flan-t5-base", device=-1)
|
@@ -23,7 +21,8 @@ Summarize the following article content in a clear, warm, and motivational tone
|
|
23 |
Summary:
|
24 |
""")
|
25 |
|
26 |
-
|
|
|
27 |
|
28 |
# TTS model setup
|
29 |
tts_model = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
|
@@ -48,7 +47,6 @@ def generate_human_like_audio(text):
|
|
48 |
|
49 |
tts_model.tts_to_file(text=text, file_path=wav_path)
|
50 |
|
51 |
-
# Convert to mp3 for download link (requires ffmpeg in Hugging Face Spaces)
|
52 |
os.system(f"ffmpeg -y -i {wav_path} -codec:a libmp3lame -qscale:a 4 {mp3_path}")
|
53 |
|
54 |
if os.path.exists(mp3_path):
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from langchain.prompts import PromptTemplate
|
3 |
+
from langchain_community.llms import HuggingFacePipeline # Updated import path
|
4 |
from transformers import pipeline
|
5 |
from bs4 import BeautifulSoup
|
6 |
import requests
|
7 |
from TTS.api import TTS
|
8 |
import tempfile
|
9 |
import os
|
|
|
10 |
|
11 |
# Setup summarization LLM
|
12 |
summary_pipe = pipeline("text2text-generation", model="google/flan-t5-base", device=-1)
|
|
|
21 |
Summary:
|
22 |
""")
|
23 |
|
24 |
+
# Updated chaining method
|
25 |
+
summary_chain = summary_prompt | llm
|
26 |
|
27 |
# TTS model setup
|
28 |
tts_model = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)
|
|
|
47 |
|
48 |
tts_model.tts_to_file(text=text, file_path=wav_path)
|
49 |
|
|
|
50 |
os.system(f"ffmpeg -y -i {wav_path} -codec:a libmp3lame -qscale:a 4 {mp3_path}")
|
51 |
|
52 |
if os.path.exists(mp3_path):
|