Spaces:
Running
Running
CSS iframe
Browse files
app.py
CHANGED
|
@@ -10,7 +10,6 @@ API_URL = "https://aura.authot.app/api/v1/punctuates"
|
|
| 10 |
|
| 11 |
def submit_punctuation_task(text, lang="fr"):
|
| 12 |
print("Création d'un fichier temporaire pour le texte...")
|
| 13 |
-
# Crée un fichier temporaire pour stocker le texte
|
| 14 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode='w', encoding='utf-8') as temp_file:
|
| 15 |
temp_file.write(text)
|
| 16 |
temp_file_path = temp_file.name
|
|
@@ -30,7 +29,6 @@ def submit_punctuation_task(text, lang="fr"):
|
|
| 30 |
}
|
| 31 |
response = requests.post(url, headers=headers, files=files, data=data)
|
| 32 |
|
| 33 |
-
# Supprime le fichier temporaire après l'envoi
|
| 34 |
os.remove(temp_file_path)
|
| 35 |
print("Fichier temporaire supprimé.")
|
| 36 |
|
|
@@ -80,12 +78,10 @@ def greet(name, progress=gr.Progress()):
|
|
| 80 |
time.sleep(1)
|
| 81 |
progress(0.05)
|
| 82 |
|
| 83 |
-
# Submit the punctuation task
|
| 84 |
task_info = submit_punctuation_task(name)
|
| 85 |
task_id = task_info["data"]["id"]
|
| 86 |
print(f"Tâche de ponctuation soumise avec l'ID : {task_id}")
|
| 87 |
|
| 88 |
-
# Check the status of the task
|
| 89 |
while True:
|
| 90 |
task_status = check_task_status(task_id)
|
| 91 |
status = task_status["data"]["attributes"]["status"]
|
|
@@ -99,14 +95,32 @@ def greet(name, progress=gr.Progress()):
|
|
| 99 |
print("La tâche a échoué ou a été annulée.")
|
| 100 |
return "La tâche a échoué ou a été annulée."
|
| 101 |
|
| 102 |
-
time.sleep(2)
|
| 103 |
|
| 104 |
-
# Get the result
|
| 105 |
result_text = get_task_result(task_id)
|
| 106 |
print("Résultat récupéré avec succès.")
|
| 107 |
return result_text
|
| 108 |
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
gr.Markdown(
|
| 111 |
"""
|
| 112 |
# Outil gratuit pour améliorer la ponctuation de votre texte !
|
|
@@ -118,6 +132,5 @@ with gr.Blocks() as demo:
|
|
| 118 |
greet_btn = gr.Button("Envoyer")
|
| 119 |
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
|
| 120 |
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
demo.launch()
|
|
|
|
| 10 |
|
| 11 |
def submit_punctuation_task(text, lang="fr"):
|
| 12 |
print("Création d'un fichier temporaire pour le texte...")
|
|
|
|
| 13 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode='w', encoding='utf-8') as temp_file:
|
| 14 |
temp_file.write(text)
|
| 15 |
temp_file_path = temp_file.name
|
|
|
|
| 29 |
}
|
| 30 |
response = requests.post(url, headers=headers, files=files, data=data)
|
| 31 |
|
|
|
|
| 32 |
os.remove(temp_file_path)
|
| 33 |
print("Fichier temporaire supprimé.")
|
| 34 |
|
|
|
|
| 78 |
time.sleep(1)
|
| 79 |
progress(0.05)
|
| 80 |
|
|
|
|
| 81 |
task_info = submit_punctuation_task(name)
|
| 82 |
task_id = task_info["data"]["id"]
|
| 83 |
print(f"Tâche de ponctuation soumise avec l'ID : {task_id}")
|
| 84 |
|
|
|
|
| 85 |
while True:
|
| 86 |
task_status = check_task_status(task_id)
|
| 87 |
status = task_status["data"]["attributes"]["status"]
|
|
|
|
| 95 |
print("La tâche a échoué ou a été annulée.")
|
| 96 |
return "La tâche a échoué ou a été annulée."
|
| 97 |
|
| 98 |
+
time.sleep(2)
|
| 99 |
|
|
|
|
| 100 |
result_text = get_task_result(task_id)
|
| 101 |
print("Résultat récupéré avec succès.")
|
| 102 |
return result_text
|
| 103 |
|
| 104 |
+
# Définir un thème personnalisé
|
| 105 |
+
custom_theme = gr.themes.Default(
|
| 106 |
+
primary_hue="amber",
|
| 107 |
+
secondary_hue="pink",
|
| 108 |
+
neutral_hue="gray",
|
| 109 |
+
font=["sans-serif", "Arial", "Helvetica"],
|
| 110 |
+
).set(
|
| 111 |
+
background_fill_primary="#FEF3E6",
|
| 112 |
+
background_fill_secondary="#FEF3E6",
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
# Créer l'application Gradio avec le thème personnalisé
|
| 116 |
+
with gr.Blocks(theme=custom_theme) as demo:
|
| 117 |
+
gr.HTML("""
|
| 118 |
+
<style>
|
| 119 |
+
footer {display: none !important;}
|
| 120 |
+
</style>
|
| 121 |
+
""")
|
| 122 |
+
|
| 123 |
+
|
| 124 |
gr.Markdown(
|
| 125 |
"""
|
| 126 |
# Outil gratuit pour améliorer la ponctuation de votre texte !
|
|
|
|
| 132 |
greet_btn = gr.Button("Envoyer")
|
| 133 |
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet")
|
| 134 |
|
| 135 |
+
# Lancer l'application
|
| 136 |
+
demo.launch()
|
|
|