Spaces:
Running
Running
File size: 2,482 Bytes
4300fed 5fe16b1 af0313a 5fe16b1 532dc11 5fe16b1 1bb2f76 5fe16b1 1bb2f76 5fe16b1 a3bb4a3 af0313a 1bb2f76 6665213 5fe16b1 4300fed 5fe16b1 1bb2f76 5fe16b1 1bb2f76 5fe16b1 f70a183 2b1a52d f70a183 abe6429 94a3228 f70a183 5fe16b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
import gradio as gr
import os
import asyncio
from conver import ConversationConfig, URLToAudioConverter
from dotenv import load_dotenv
load_dotenv()
def synthesize_sync(article_url):
return asyncio.run(synthesize(article_url))
async def synthesize(article_url):
if not article_url:
return "Please provide a valid URL.", None
try:
config = ConversationConfig()
converter = URLToAudioConverter(config, llm_api_key=os.environ.get("TOGETHER_API_KEY"))
output_file, conversation = await converter.url_to_audio(
article_url,
"en-US-AvaMultilingualNeural",
"en-US-AndrewMultilingualNeural"
)
return conversation, output_file
except Exception as e:
return f"Error: {str(e)}", None
with gr.Blocks(theme='gstaff/sketch') as demo:
gr.Markdown("# Turn Any Article into a Podcast")
gr.Markdown("## Easily convert articles from URLs into listenable audio podcasts.")
gr.Markdown("### Instructions")
gr.Markdown("""
- **Step 1:** Paste the URL of the article you want to convert into the textbox.
- **Step 2:** Click on "Podcastify" to generate the podcast.
- **Step 3:** Listen to the podcast or view the conversation.
""")
gr.Markdown("""
- View the code at [GitHub - NarrateIt](https://github.com/EswarDivi/NarrateIt).
""")
with gr.Group():
text = gr.Textbox(label="Article Link", placeholder="Enter the article URL here...")
btn = gr.Button("Podcastify", variant="primary")
with gr.Row():
conv_display = gr.Textbox(label="Conversation", interactive=False, lines=10)
aud = gr.Audio(label="Generated Podcast", interactive=False)
gr.Examples(
examples=["https://huggingface.co/blog/gradio-mcp"],
inputs=text,
fn=synthesize_sync,
outputs=[conv_display, aud]
)
btn.click(synthesize_sync, inputs=[text], outputs=[conv_display, aud])
gr.Markdown("""
Note:
The initial version of Podcastify, which was purely local and used an open-source and on-device models, has been replaced by the current one. You can find it in the local branch.
Special thanks to:
- [gstaff/sketch](https://huggingface.co/spaces/gstaff/sketch) for the Sketch Theme.
- [Jina AI](https://jina.ai/reader/) for the web page parsing.
""")
demo.queue(api_open=True, default_concurrency_limit=15).launch(show_api=True)
|