Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -62,17 +62,24 @@ def process_youtube_or_audio(url, uploaded_audio, start_time, end_time):
|
|
62 |
print(f"Error: {e}")
|
63 |
return None, None
|
64 |
|
65 |
-
# Gradio
|
66 |
with gr.Blocks() as interface:
|
67 |
gr.HTML("""
|
68 |
<h1 style="font-size: 2rem; text-align: center;"><i class="fas fa-music"></i> PYTR - Python YouTube Ringtones</h1>
|
69 |
<p style="text-align: center;">Enter a YouTube URL or upload an audio file to create ringtones.</p>
|
70 |
<p style="text-align: center;"><a href="https://ringtones.jessejesse.xyz">Ringtones</a> | <a href="https://github.com/sudo-self/pytr">GitHub</a></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
""")
|
72 |
|
73 |
with gr.Row():
|
74 |
-
youtube_url = gr.Textbox(placeholder="Enter the URL here...", label="YouTube URL",
|
75 |
-
uploaded_audio = gr.File(label="Upload Audio File", type="filepath",
|
76 |
|
77 |
gr.HTML("<h3 style='text-align: center;'>Trim Audio</h3>")
|
78 |
|
@@ -80,19 +87,19 @@ with gr.Blocks() as interface:
|
|
80 |
start_time = gr.Slider(0, 20, value=0, label="Start Time (seconds)", style={"width": "45%"})
|
81 |
end_time = gr.Slider(1, 20, value=20, label="End Time (seconds)", style={"width": "45%"})
|
82 |
|
83 |
-
|
84 |
-
process_button = gr.Button("Create Ringtones",
|
85 |
|
86 |
with gr.Row():
|
87 |
-
mp3_download = gr.File(label="Android Ringtone",
|
88 |
-
iphone_ringtone = gr.File(label="iPhone Ringtone",
|
89 |
|
90 |
with gr.Row():
|
91 |
instructions = gr.Textbox(
|
92 |
value="Android: move the download to the 'Ringtones' folder.\nApple: import download with 'Garage Band' and export to ringtones.",
|
93 |
label="Install Ringtones",
|
94 |
interactive=False,
|
95 |
-
|
96 |
)
|
97 |
|
98 |
process_button.click(process_youtube_or_audio, inputs=[youtube_url, uploaded_audio, start_time, end_time], outputs=[mp3_download, iphone_ringtone])
|
|
|
62 |
print(f"Error: {e}")
|
63 |
return None, None
|
64 |
|
65 |
+
# Gradio Interface
|
66 |
with gr.Blocks() as interface:
|
67 |
gr.HTML("""
|
68 |
<h1 style="font-size: 2rem; text-align: center;"><i class="fas fa-music"></i> PYTR - Python YouTube Ringtones</h1>
|
69 |
<p style="text-align: center;">Enter a YouTube URL or upload an audio file to create ringtones.</p>
|
70 |
<p style="text-align: center;"><a href="https://ringtones.jessejesse.xyz">Ringtones</a> | <a href="https://github.com/sudo-self/pytr">GitHub</a></p>
|
71 |
+
|
72 |
+
<style>
|
73 |
+
#youtube-url, #uploaded-audio { width: 45%; }
|
74 |
+
#process-button { width: 100%; margin-top: 10px; background-color: #6a4cfc; color: white; border: none; border-radius: 5px; }
|
75 |
+
#mp3-download, #iphone-ringtone { width: 45%; }
|
76 |
+
#instructions { width: 100%; margin-top: 20px; }
|
77 |
+
</style>
|
78 |
""")
|
79 |
|
80 |
with gr.Row():
|
81 |
+
youtube_url = gr.Textbox(placeholder="Enter the URL here...", label="YouTube URL", elem_id="youtube-url")
|
82 |
+
uploaded_audio = gr.File(label="Upload Audio File", type="filepath", elem_id="uploaded-audio")
|
83 |
|
84 |
gr.HTML("<h3 style='text-align: center;'>Trim Audio</h3>")
|
85 |
|
|
|
87 |
start_time = gr.Slider(0, 20, value=0, label="Start Time (seconds)", style={"width": "45%"})
|
88 |
end_time = gr.Slider(1, 20, value=20, label="End Time (seconds)", style={"width": "45%"})
|
89 |
|
90 |
+
|
91 |
+
process_button = gr.Button("Create Ringtones", elem_id="process-button")
|
92 |
|
93 |
with gr.Row():
|
94 |
+
mp3_download = gr.File(label="Android Ringtone", elem_id="mp3-download")
|
95 |
+
iphone_ringtone = gr.File(label="iPhone Ringtone", elem_id="iphone-ringtone")
|
96 |
|
97 |
with gr.Row():
|
98 |
instructions = gr.Textbox(
|
99 |
value="Android: move the download to the 'Ringtones' folder.\nApple: import download with 'Garage Band' and export to ringtones.",
|
100 |
label="Install Ringtones",
|
101 |
interactive=False,
|
102 |
+
elem_id="instructions"
|
103 |
)
|
104 |
|
105 |
process_button.click(process_youtube_or_audio, inputs=[youtube_url, uploaded_audio, start_time, end_time], outputs=[mp3_download, iphone_ringtone])
|