Spaces:
Runtime error
Runtime error
Kabatubare
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import art
|
3 |
+
|
4 |
+
def advanced_ascii_art(message, style):
|
5 |
+
# Use the 'art' package to generate a wide variety of ASCII art styles
|
6 |
+
try:
|
7 |
+
ascii_art = art.text2art(message, font=style)
|
8 |
+
except art.art.ArtError: # Fallback if the style is not found
|
9 |
+
ascii_art = art.text2art(message) # Default style
|
10 |
+
return ascii_art
|
11 |
+
|
12 |
+
# List of available ASCII art styles from the 'art' package
|
13 |
+
styles = art.FONT_NAMES
|
14 |
+
|
15 |
+
# Create a Gradio interface with an additional dropdown for style selection
|
16 |
+
iface = gr.Interface(
|
17 |
+
fn=advanced_ascii_art,
|
18 |
+
inputs=["text", gr.inputs.Dropdown(choices=styles, label="Style")],
|
19 |
+
outputs="text",
|
20 |
+
title="Advanced ASCII Art Generator",
|
21 |
+
description="Enter your message and select a style to generate advanced ASCII art."
|
22 |
+
)
|
23 |
+
|
24 |
+
# Deploy the app to Hugging Face Spaces with share=True
|
25 |
+
iface.launch(share=True)
|