Spaces:
Running
Running
File size: 1,563 Bytes
4300fed 5fe16b1 af0313a 5fe16b1 532dc11 5fe16b1 1bb2f76 5fe16b1 1bb2f76 5fe16b1 a3bb4a3 c25388b 5fe16b1 4300fed c25388b 1bb2f76 5fe16b1 1bb2f76 5fe16b1 2677e2a 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 |
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='soft') as demo:
with gr.Group():
text = gr.Textbox(label="Link: Article, Blog, News...", 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/openfree/cycle-navigator"],
inputs=text,
fn=synthesize_sync,
outputs=[conv_display, aud]
)
btn.click(synthesize_sync, inputs=[text], outputs=[conv_display, aud])
demo.queue(api_open=True, default_concurrency_limit=15).launch(show_api=True)
|