Ronaldodev's picture
Update app.py
c5d703a verified
raw
history blame contribute delete
968 Bytes
import gradio as gr
from pdf_utils import extract_text_pdf, clean_extracted_text, split_paragraphs, create_clean_pdf
from translator import translate_fr_to_fon
def process_pdf(file):
pages = extract_text_pdf(file.name)
# Nettoyage du texte
cleaned_pages = [clean_extracted_text(p) for p in pages]
translated_pages = []
for page in cleaned_pages:
chunks = split_paragraphs(page)
translated_chunks = translate_fr_to_fon(chunks)
translated_pages.append(" ".join(translated_chunks))
final_text = "\n\n".join(translated_pages)
output_path = "pdf_fon_traduit.pdf"
create_clean_pdf(final_text, output_path)
return output_path
# --- Interface Gradio ---
gr.Interface(
fn=process_pdf,
inputs=gr.File(label="PDF en français"),
outputs=gr.File(label="PDF traduit en Fon"),
title="Traducteur PDF Français → Fon",
description="Traduction automatique de documents PDF vers le Fon"
).launch()