Spaces:
Running
on
Zero
Running
on
Zero
added new theme
Browse files- README.md +2 -2
- app.py +54 -11
- themes/themes_theme_schema@0.0.1.json +1 -0
README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
---
|
2 |
title: Podcastify
|
3 |
sdk: gradio
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
emoji: 🗣️
|
7 |
license: mit
|
8 |
app_file: app.py
|
|
|
1 |
---
|
2 |
title: Podcastify
|
3 |
sdk: gradio
|
4 |
+
colorFrom: gray
|
5 |
+
colorTo: gray
|
6 |
emoji: 🗣️
|
7 |
license: mit
|
8 |
app_file: app.py
|
app.py
CHANGED
@@ -3,17 +3,36 @@ import spaces
|
|
3 |
import os, torch, io
|
4 |
import json
|
5 |
import re
|
6 |
-
os.system("python -m unidic download")
|
7 |
import httpx
|
8 |
# print("Make sure you've downloaded unidic (python -m unidic download) for this WebUI to work.")
|
9 |
from melo.api import TTS
|
10 |
import tempfile
|
11 |
import wave
|
12 |
from pydub import AudioSegment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
from gradio_client import Client
|
14 |
|
15 |
client = Client("eswardivi/AIO_Chat")
|
|
|
|
|
|
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def validate_url(url):
|
18 |
try:
|
19 |
response = httpx.get(url, timeout=60.0)
|
@@ -30,6 +49,8 @@ def fetch_text(url):
|
|
30 |
print("Entered Webpage Extraction")
|
31 |
prefix_url = "https://r.jina.ai/"
|
32 |
full_url = prefix_url + url
|
|
|
|
|
33 |
return validate_url(full_url)
|
34 |
@spaces.GPU
|
35 |
def synthesize(article_url,progress_audio=gr.Progress()):
|
@@ -41,7 +62,6 @@ def synthesize(article_url,progress_audio=gr.Progress()):
|
|
41 |
return text, None
|
42 |
|
43 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
44 |
-
|
45 |
template = """
|
46 |
{
|
47 |
"conversation": [
|
@@ -50,16 +70,39 @@ def synthesize(article_url,progress_audio=gr.Progress()):
|
|
50 |
]
|
51 |
}
|
52 |
"""
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
pattern = r"\{(?:[^{}]|(?:\{[^{}]*\}))*\}"
|
62 |
-
json_match = re.search(pattern,
|
63 |
if json_match:
|
64 |
conversation=json_match.group()
|
65 |
else:
|
@@ -84,7 +127,7 @@ def synthesize(article_url,progress_audio=gr.Progress()):
|
|
84 |
return conversation, final_audio_path
|
85 |
|
86 |
|
87 |
-
with gr.Blocks() as demo:
|
88 |
gr.Markdown("# Turn Any Article into a Podcast")
|
89 |
gr.Markdown("## Easily convert articles from URLs into listenable audio podcasts.")
|
90 |
gr.Markdown("### Instructions")
|
|
|
3 |
import os, torch, io
|
4 |
import json
|
5 |
import re
|
6 |
+
# os.system("python -m unidic download")
|
7 |
import httpx
|
8 |
# print("Make sure you've downloaded unidic (python -m unidic download) for this WebUI to work.")
|
9 |
from melo.api import TTS
|
10 |
import tempfile
|
11 |
import wave
|
12 |
from pydub import AudioSegment
|
13 |
+
from transformers import (
|
14 |
+
AutoModelForCausalLM,
|
15 |
+
AutoTokenizer,
|
16 |
+
TextIteratorStreamer,
|
17 |
+
BitsAndBytesConfig,
|
18 |
+
)
|
19 |
+
from threading import Thread
|
20 |
+
|
21 |
from gradio_client import Client
|
22 |
|
23 |
client = Client("eswardivi/AIO_Chat")
|
24 |
+
quantization_config = BitsAndBytesConfig(
|
25 |
+
load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16
|
26 |
+
)
|
27 |
|
28 |
+
model = AutoModelForCausalLM.from_pretrained(
|
29 |
+
"NousResearch/Hermes-2-Pro-Llama-3-8B", quantization_config=quantization_config
|
30 |
+
)
|
31 |
+
tok = AutoTokenizer.from_pretrained("NousResearch/Hermes-2-Pro-Llama-3-8B")
|
32 |
+
terminators = [
|
33 |
+
tok.eos_token_id,
|
34 |
+
tok.convert_tokens_to_ids("<|eot_id|>")
|
35 |
+
]
|
36 |
def validate_url(url):
|
37 |
try:
|
38 |
response = httpx.get(url, timeout=60.0)
|
|
|
49 |
print("Entered Webpage Extraction")
|
50 |
prefix_url = "https://r.jina.ai/"
|
51 |
full_url = prefix_url + url
|
52 |
+
print(full_url)
|
53 |
+
print("Exited Webpage Extraction")
|
54 |
return validate_url(full_url)
|
55 |
@spaces.GPU
|
56 |
def synthesize(article_url,progress_audio=gr.Progress()):
|
|
|
62 |
return text, None
|
63 |
|
64 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
65 |
template = """
|
66 |
{
|
67 |
"conversation": [
|
|
|
70 |
]
|
71 |
}
|
72 |
"""
|
73 |
+
chat = []
|
74 |
+
chat.append({"role": "user", "content": "{text} \n Convert the text as Elaborate Conversation between two people as Podcast.\nfollowing this template and return only JSON \n {template}"})
|
75 |
+
messages = tok.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
76 |
+
model_inputs = tok([messages], return_tensors="pt").to(device)
|
77 |
+
streamer = TextIteratorStreamer(
|
78 |
+
tok, timeout=10.0, skip_prompt=True, skip_special_tokens=True
|
79 |
+
)
|
80 |
+
generate_kwargs = dict(
|
81 |
+
model_inputs,
|
82 |
+
streamer=streamer,
|
83 |
+
max_new_tokens=1024,
|
84 |
+
do_sample=True,
|
85 |
+
temperature=0.9,
|
86 |
+
eos_token_id=terminators,
|
87 |
)
|
88 |
+
t = Thread(target=model.generate, kwargs=generate_kwargs)
|
89 |
+
t.start()
|
90 |
+
|
91 |
+
partial_text = ""
|
92 |
+
for new_text in streamer:
|
93 |
+
partial_text += new_text
|
94 |
+
|
95 |
+
# print("Calling API")
|
96 |
+
# result = client.predict(
|
97 |
+
# f"{text} \n Convert the text as Elaborate Conversation between two people as Podcast.\nfollowing this template and return only JSON \n {template}",
|
98 |
+
# 0.9,
|
99 |
+
# True,
|
100 |
+
# 1024,
|
101 |
+
# api_name="/chat"
|
102 |
+
# )
|
103 |
+
# print("API Call Completed")
|
104 |
pattern = r"\{(?:[^{}]|(?:\{[^{}]*\}))*\}"
|
105 |
+
json_match = re.search(pattern, partial_text)
|
106 |
if json_match:
|
107 |
conversation=json_match.group()
|
108 |
else:
|
|
|
127 |
return conversation, final_audio_path
|
128 |
|
129 |
|
130 |
+
with gr.Blocks(theme='gstaff/sketch') as demo:
|
131 |
gr.Markdown("# Turn Any Article into a Podcast")
|
132 |
gr.Markdown("## Easily convert articles from URLs into listenable audio podcasts.")
|
133 |
gr.Markdown("### Instructions")
|
themes/themes_theme_schema@0.0.1.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"theme": {"_font": [{"__gradio_font__": true, "name": "Shantell Sans", "class": "google"}, {"__gradio_font__": true, "name": "ui-sans-serif", "class": "font"}, {"__gradio_font__": true, "name": "sans-serif", "class": "font"}], "_font_mono": [{"__gradio_font__": true, "name": "IBM Plex Mono", "class": "google"}, {"__gradio_font__": true, "name": "ui-monospace", "class": "font"}, {"__gradio_font__": true, "name": "monospace", "class": "font"}], "_stylesheets": ["https://fonts.googleapis.com/css2?family=Shantell+Sans:wght@400;600&display=swap", "https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&display=swap"], "background_fill_primary": "white", "background_fill_primary_dark": "*neutral_900", "background_fill_secondary": "*neutral_50", "background_fill_secondary_dark": "*neutral_800", "block_background_fill": "*background_fill_primary", "block_background_fill_dark": "*neutral_800", "block_border_color": "*border_color_primary", "block_border_color_dark": "*border_color_primary", "block_border_width": "0px", "block_border_width_dark": "1px", "block_info_text_color": "*body_text_color_subdued", "block_info_text_color_dark": "*body_text_color_subdued", "block_info_text_size": "*text_sm", "block_info_text_weight": "400", "block_label_background_fill": "*background_fill_primary", "block_label_background_fill_dark": "*background_fill_secondary", "block_label_border_color": "*border_color_primary", "block_label_border_color_dark": "*border_color_primary", "block_label_border_width": "1px", "block_label_margin": "0", "block_label_padding": "*spacing_sm *spacing_lg", "block_label_radius": "calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px) 0", "block_label_right_radius": "0 calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px)", "block_label_text_color": "*body_text_color", "block_label_text_color_dark": "*neutral_200", "block_label_text_size": "*text_md", "block_label_text_weight": "600", "block_padding": "*spacing_xl calc(*spacing_xl + 2px)", "block_radius": "*radius_lg", "block_shadow": "*shadow_drop_lg", "block_shadow_dark": "none", "block_title_background_fill": "none", "block_title_border_color": "none", "block_title_border_width": "0px", "block_title_padding": "0", "block_title_radius": "none", "block_title_text_color": "*body_text_color", "block_title_text_color_dark": "*neutral_200", "block_title_text_size": "*text_md", "block_title_text_weight": "600", "body_background_fill": "*background_fill_primary", "body_background_fill_dark": "*background_fill_primary", "body_text_color": "*neutral_900", "body_text_color_dark": "*neutral_100", "body_text_color_subdued": "*neutral_700", "body_text_color_subdued_dark": "*neutral_400", "body_text_size": "*text_md", "body_text_weight": "400", "border_color_accent": "*primary_300", "border_color_accent_dark": "*neutral_600", "border_color_primary": "*neutral_200", "border_color_primary_dark": "*neutral_700", "button_border_width": "*input_border_width", "button_border_width_dark": "*input_border_width", "button_cancel_background_fill": "*button_primary_background_fill", "button_cancel_background_fill_dark": "*button_secondary_background_fill", "button_cancel_background_fill_hover": "*button_primary_background_fill_hover", "button_cancel_background_fill_hover_dark": "*button_cancel_background_fill", "button_cancel_border_color": "*button_secondary_border_color", "button_cancel_border_color_dark": "*button_secondary_border_color", "button_cancel_border_color_hover": "*button_cancel_border_color", "button_cancel_border_color_hover_dark": "*button_cancel_border_color", "button_cancel_text_color": "*button_primary_text_color", "button_cancel_text_color_dark": "*button_secondary_text_color", "button_cancel_text_color_hover": "*button_cancel_text_color", "button_cancel_text_color_hover_dark": "*button_cancel_text_color", "button_large_padding": "*spacing_lg", "button_large_radius": "*radius_lg", "button_large_text_size": "*text_lg", "button_large_text_weight": "600", "button_primary_background_fill": "*neutral_900", "button_primary_background_fill_dark": "*neutral_600", "button_primary_background_fill_hover": "*neutral_700", "button_primary_background_fill_hover_dark": "*neutral_600", "button_primary_border_color": "*primary_200", "button_primary_border_color_dark": "*primary_600", "button_primary_border_color_hover": "*button_primary_border_color", "button_primary_border_color_hover_dark": "*button_primary_border_color", "button_primary_text_color": "white", "button_primary_text_color_dark": "white", "button_primary_text_color_hover": "*button_primary_text_color", "button_primary_text_color_hover_dark": "*button_primary_text_color", "button_secondary_background_fill": "*button_primary_background_fill", "button_secondary_background_fill_dark": "*neutral_600", "button_secondary_background_fill_hover": "*button_primary_background_fill_hover", "button_secondary_background_fill_hover_dark": "*button_secondary_background_fill", "button_secondary_border_color": "*neutral_200", "button_secondary_border_color_dark": "*neutral_600", "button_secondary_border_color_hover": "*button_secondary_border_color", "button_secondary_border_color_hover_dark": "*button_secondary_border_color", "button_secondary_text_color": "*button_primary_text_color", "button_secondary_text_color_dark": "white", "button_secondary_text_color_hover": "*button_secondary_text_color", "button_secondary_text_color_hover_dark": "*button_secondary_text_color", "button_shadow": "none", "button_shadow_active": "none", "button_shadow_hover": "none", "button_small_padding": "*spacing_sm", "button_small_radius": "*radius_lg", "button_small_text_size": "*text_md", "button_small_text_weight": "400", "button_transition": "background-color 0.2s ease", "checkbox_background_color": "*background_fill_primary", "checkbox_background_color_dark": "*neutral_700", "checkbox_background_color_focus": "*checkbox_background_color", "checkbox_background_color_focus_dark": "*checkbox_background_color", "checkbox_background_color_hover": "*checkbox_background_color", "checkbox_background_color_hover_dark": "*checkbox_background_color", "checkbox_background_color_selected": "*neutral_600", "checkbox_background_color_selected_dark": "*neutral_700", "checkbox_border_color": "*neutral_300", "checkbox_border_color_dark": "*neutral_700", "checkbox_border_color_focus": "*secondary_500", "checkbox_border_color_focus_dark": "*secondary_500", "checkbox_border_color_hover": "*neutral_300", "checkbox_border_color_hover_dark": "*neutral_600", "checkbox_border_color_selected": "*secondary_600", "checkbox_border_color_selected_dark": "*neutral_800", "checkbox_border_radius": "*radius_sm", "checkbox_border_width": "*input_border_width", "checkbox_border_width_dark": "*input_border_width", "checkbox_check": "url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e\")", "checkbox_label_background_fill": "*button_primary_background_fill", "checkbox_label_background_fill_dark": "*button_secondary_background_fill", "checkbox_label_background_fill_hover": "*button_primary_background_fill_hover", "checkbox_label_background_fill_hover_dark": "*button_secondary_background_fill_hover", "checkbox_label_background_fill_selected": "*checkbox_label_background_fill", "checkbox_label_background_fill_selected_dark": "*checkbox_label_background_fill", "checkbox_label_border_color": "*border_color_primary", "checkbox_label_border_color_dark": "*border_color_primary", "checkbox_label_border_color_hover": "*checkbox_label_border_color", "checkbox_label_border_color_hover_dark": "*checkbox_label_border_color", "checkbox_label_border_width": "*input_border_width", "checkbox_label_border_width_dark": "*input_border_width", "checkbox_label_gap": "*spacing_lg", "checkbox_label_padding": "*spacing_md", "checkbox_label_shadow": "none", "checkbox_label_text_color": "*button_primary_text_color", "checkbox_label_text_color_dark": "*body_text_color", "checkbox_label_text_color_selected": "*checkbox_label_text_color", "checkbox_label_text_color_selected_dark": "*checkbox_label_text_color", "checkbox_label_text_size": "*text_md", "checkbox_label_text_weight": "400", "checkbox_shadow": "*input_shadow", "color_accent": "*primary_500", "color_accent_soft": "*primary_50", "color_accent_soft_dark": "*neutral_700", "container_radius": "*radius_lg", "embed_radius": "*radius_lg", "error_background_fill": "#fee2e2", "error_background_fill_dark": "*background_fill_primary", "error_border_color": "#fecaca", "error_border_color_dark": "*border_color_primary", "error_border_width": "1px", "error_text_color": "#ef4444", "error_text_color_dark": "#ef4444", "font": "'Shantell Sans', 'ui-sans-serif', sans-serif", "font_mono": "'IBM Plex Mono', 'ui-monospace', monospace", "form_gap_width": "0px", "input_background_fill": "*neutral_100", "input_background_fill_dark": "*neutral_700", "input_background_fill_focus": "*secondary_500", "input_background_fill_focus_dark": "*secondary_600", "input_background_fill_hover": "*input_background_fill", "input_background_fill_hover_dark": "*input_background_fill", "input_border_color": "*border_color_primary", "input_border_color_dark": "*border_color_primary", "input_border_color_focus": "*secondary_300", "input_border_color_focus_dark": "*neutral_700", "input_border_color_hover": "*input_border_color", "input_border_color_hover_dark": "*input_border_color", "input_border_width": "0px", "input_padding": "*spacing_xl", "input_placeholder_color": "*neutral_400", "input_placeholder_color_dark": "*neutral_500", "input_radius": "*radius_lg", "input_shadow": "none", "input_shadow_focus": "*input_shadow", "input_text_size": "*text_md", "input_text_weight": "400", "layout_gap": "*spacing_xxl", "link_text_color": "*secondary_600", "link_text_color_active": "*secondary_600", "link_text_color_active_dark": "*secondary_500", "link_text_color_dark": "*secondary_500", "link_text_color_hover": "*secondary_700", "link_text_color_hover_dark": "*secondary_400", "link_text_color_visited": "*secondary_500", "link_text_color_visited_dark": "*secondary_600", "loader_color": "*color_accent", "neutral_100": "#f5f5f5", "neutral_200": "#e5e5e5", "neutral_300": "#d4d4d4", "neutral_400": "#a3a3a3", "neutral_50": "#fafafa", "neutral_500": "#737373", "neutral_600": "#525252", "neutral_700": "#404040", "neutral_800": "#262626", "neutral_900": "#171717", "neutral_950": "#0f0f0f", "panel_background_fill": "*background_fill_secondary", "panel_background_fill_dark": "*background_fill_secondary", "panel_border_color": "*border_color_primary", "panel_border_color_dark": "*border_color_primary", "panel_border_width": "0", "primary_100": "#f5f5f5", "primary_200": "#e5e5e5", "primary_300": "#d4d4d4", "primary_400": "#a3a3a3", "primary_50": "#fafafa", "primary_500": "#737373", "primary_600": "#525252", "primary_700": "#404040", "primary_800": "#262626", "primary_900": "#171717", "primary_950": "#0f0f0f", "prose_header_text_weight": "600", "prose_text_size": "*text_md", "prose_text_weight": "400", "radio_circle": "url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e\")", "radius_lg": "8px", "radius_md": "6px", "radius_sm": "4px", "radius_xl": "12px", "radius_xs": "2px", "radius_xxl": "22px", "radius_xxs": "1px", "secondary_100": "#f5f5f5", "secondary_200": "#e5e5e5", "secondary_300": "#d4d4d4", "secondary_400": "#a3a3a3", "secondary_50": "#fafafa", "secondary_500": "#737373", "secondary_600": "#525252", "secondary_700": "#404040", "secondary_800": "#262626", "secondary_900": "#171717", "secondary_950": "#0f0f0f", "section_header_text_size": "*text_md", "section_header_text_weight": "400", "shadow_drop": "rgba(0,0,0,0.05) 0px 1px 2px 0px", "shadow_drop_lg": "0 1px 4px 0 rgb(0 0 0 / 0.1)", "shadow_inset": "rgba(0,0,0,0.05) 0px 2px 4px 0px inset", "shadow_spread": "3px", "shadow_spread_dark": "1px", "slider_color": "*neutral_900", "slider_color_dark": "*neutral_500", "spacing_lg": "8px", "spacing_md": "6px", "spacing_sm": "4px", "spacing_xl": "10px", "spacing_xs": "2px", "spacing_xxl": "16px", "spacing_xxs": "1px", "stat_background_fill": "*primary_300", "stat_background_fill_dark": "*primary_500", "table_border_color": "*neutral_300", "table_border_color_dark": "*neutral_700", "table_even_background_fill": "white", "table_even_background_fill_dark": "*neutral_950", "table_odd_background_fill": "*neutral_50", "table_odd_background_fill_dark": "*neutral_900", "table_radius": "*radius_lg", "table_row_focus": "*color_accent_soft", "table_row_focus_dark": "*color_accent_soft", "text_lg": "20px", "text_md": "16px", "text_sm": "14px", "text_xl": "24px", "text_xs": "12px", "text_xxl": "28px", "text_xxs": "10px"}, "version": "0.0.1"}
|