Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -943,72 +943,16 @@ def display_transcription_and_summary(transcription: str):
|
|
943 |
st.markdown(summary)
|
944 |
|
945 |
# Génération et téléchargement des documents
|
946 |
-
generate_and_download_documents(summary)
|
947 |
|
948 |
# Option d'envoi par email
|
949 |
-
handle_email_sending(summary)
|
|
|
|
|
950 |
|
951 |
-
def generate_and_download_documents(summary: str):
|
952 |
-
"""Génération et téléchargement des documents"""
|
953 |
-
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
954 |
-
|
955 |
-
# Génération PDF
|
956 |
-
pdf_filename = f"resume_{timestamp}.pdf"
|
957 |
-
pdf_path = PDFGenerator.create_pdf(summary, pdf_filename)
|
958 |
-
|
959 |
-
# Génération DOCX
|
960 |
-
docx_filename = f"resume_{timestamp}.docx"
|
961 |
-
docx_path = generate_docx(summary, docx_filename)
|
962 |
-
|
963 |
-
# Boutons de téléchargement avec des clés uniques
|
964 |
-
col1, col2 = st.columns(2)
|
965 |
-
with col1:
|
966 |
-
with open(pdf_path, "rb") as pdf_file:
|
967 |
-
st.download_button(
|
968 |
-
"📥 Télécharger PDF",
|
969 |
-
pdf_file,
|
970 |
-
file_name=pdf_filename,
|
971 |
-
mime="application/pdf",
|
972 |
-
key=f"download_pdf_{uuid.uuid4()}" # Utilisation d'un UUID
|
973 |
-
)
|
974 |
-
|
975 |
-
with col2:
|
976 |
-
with open(docx_path, "rb") as docx_file:
|
977 |
-
st.download_button(
|
978 |
-
"📥 Télécharger DOCX",
|
979 |
-
docx_file,
|
980 |
-
file_name=docx_filename,
|
981 |
-
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
982 |
-
key=f"download_docx_{uuid.uuid4()}" # Utilisation d'un UUID
|
983 |
-
)
|
984 |
-
|
985 |
-
return pdf_path
|
986 |
|
987 |
|
988 |
|
989 |
-
def handle_email_sending(summary: str):
|
990 |
-
"""Gestion de l'envoi par email"""
|
991 |
-
st.subheader("📧 Recevoir le résumé par email")
|
992 |
-
recipient_email = st.text_input("Entrez votre adresse email:")
|
993 |
-
|
994 |
-
if st.button("Envoyer par email"):
|
995 |
-
if not is_valid_email(recipient_email):
|
996 |
-
st.error("Veuillez entrer une adresse email valide.")
|
997 |
-
return
|
998 |
-
|
999 |
-
with st.spinner("Envoi de l'email en cours..."):
|
1000 |
-
pdf_path = generate_and_download_documents(summary)
|
1001 |
-
email_sender = EmailSender(SENDER_EMAIL, SENDER_PASSWORD)
|
1002 |
-
|
1003 |
-
if email_sender.send_email(
|
1004 |
-
recipient_email,
|
1005 |
-
"Résumé de votre contenu audio/vidéo",
|
1006 |
-
"Veuillez trouver ci-joint le résumé de votre contenu.",
|
1007 |
-
pdf_path
|
1008 |
-
):
|
1009 |
-
st.success("Email envoyé avec succès!")
|
1010 |
-
else:
|
1011 |
-
st.error("Échec de l'envoi de l'email.")
|
1012 |
|
1013 |
|
1014 |
def cleanup_temporary_files():
|
|
|
943 |
st.markdown(summary)
|
944 |
|
945 |
# Génération et téléchargement des documents
|
946 |
+
#generate_and_download_documents(summary)
|
947 |
|
948 |
# Option d'envoi par email
|
949 |
+
#handle_email_sending(summary)
|
950 |
+
|
951 |
+
|
952 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
953 |
|
954 |
|
955 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
956 |
|
957 |
|
958 |
def cleanup_temporary_files():
|