Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -919,20 +919,12 @@ def display_transcription_and_summary(transcription: str):
|
|
| 919 |
st.markdown(summary)
|
| 920 |
|
| 921 |
# Génération et téléchargement des documents
|
| 922 |
-
generate_and_download_documents(summary
|
| 923 |
|
| 924 |
# Option d'envoi par email
|
| 925 |
handle_email_sending(summary)
|
| 926 |
|
| 927 |
-
def
|
| 928 |
-
"""Génération du résumé"""
|
| 929 |
-
chunks = st.session_state.audio_processor.split_text(transcription)
|
| 930 |
-
if len(chunks) > 1:
|
| 931 |
-
return st.session_state.audio_processor.summarize_long_transcription(transcription)
|
| 932 |
-
return st.session_state.audio_processor.generate_summary(transcription)
|
| 933 |
-
|
| 934 |
-
|
| 935 |
-
def generate_and_download_documents(summary: str, context="main"):
|
| 936 |
"""Génération et téléchargement des documents"""
|
| 937 |
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
| 938 |
|
|
@@ -953,7 +945,7 @@ def generate_and_download_documents(summary: str, context="main"):
|
|
| 953 |
pdf_file,
|
| 954 |
file_name=pdf_filename,
|
| 955 |
mime="application/pdf",
|
| 956 |
-
key=f"
|
| 957 |
)
|
| 958 |
|
| 959 |
with col2:
|
|
@@ -963,11 +955,12 @@ def generate_and_download_documents(summary: str, context="main"):
|
|
| 963 |
docx_file,
|
| 964 |
file_name=docx_filename,
|
| 965 |
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 966 |
-
key=f"
|
| 967 |
)
|
| 968 |
|
| 969 |
return pdf_path
|
| 970 |
|
|
|
|
| 971 |
def handle_email_sending(summary: str):
|
| 972 |
"""Gestion de l'envoi par email"""
|
| 973 |
st.subheader("📧 Recevoir le résumé par email")
|
|
@@ -1068,14 +1061,43 @@ def display_summary_and_downloads(summary: str):
|
|
| 1068 |
st.markdown("### 📝 Résumé et Analyse")
|
| 1069 |
st.markdown(summary)
|
| 1070 |
|
| 1071 |
-
|
| 1072 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1073 |
|
| 1074 |
# Option d'envoi par email
|
| 1075 |
st.markdown("### 📧 Recevoir le résumé par email")
|
| 1076 |
-
recipient_email = st.text_input("Entrez votre adresse email:"
|
| 1077 |
|
| 1078 |
-
if st.button("Envoyer par email"
|
| 1079 |
if not is_valid_email(recipient_email):
|
| 1080 |
st.error("Veuillez entrer une adresse email valide.")
|
| 1081 |
else:
|
|
|
|
| 919 |
st.markdown(summary)
|
| 920 |
|
| 921 |
# Génération et téléchargement des documents
|
| 922 |
+
generate_and_download_documents(summary)
|
| 923 |
|
| 924 |
# Option d'envoi par email
|
| 925 |
handle_email_sending(summary)
|
| 926 |
|
| 927 |
+
def generate_and_download_documents(summary: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 928 |
"""Génération et téléchargement des documents"""
|
| 929 |
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
| 930 |
|
|
|
|
| 945 |
pdf_file,
|
| 946 |
file_name=pdf_filename,
|
| 947 |
mime="application/pdf",
|
| 948 |
+
key=f"download_pdf_{timestamp}" # Clé unique pour chaque bouton PDF
|
| 949 |
)
|
| 950 |
|
| 951 |
with col2:
|
|
|
|
| 955 |
docx_file,
|
| 956 |
file_name=docx_filename,
|
| 957 |
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 958 |
+
key=f"download_docx_{timestamp}" # Clé unique pour chaque bouton DOCX
|
| 959 |
)
|
| 960 |
|
| 961 |
return pdf_path
|
| 962 |
|
| 963 |
+
|
| 964 |
def handle_email_sending(summary: str):
|
| 965 |
"""Gestion de l'envoi par email"""
|
| 966 |
st.subheader("📧 Recevoir le résumé par email")
|
|
|
|
| 1061 |
st.markdown("### 📝 Résumé et Analyse")
|
| 1062 |
st.markdown(summary)
|
| 1063 |
|
| 1064 |
+
timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
|
| 1065 |
+
|
| 1066 |
+
# Génération PDF
|
| 1067 |
+
pdf_filename = f"resume_{timestamp}.pdf"
|
| 1068 |
+
pdf_path = PDFGenerator.create_pdf(summary, pdf_filename)
|
| 1069 |
+
|
| 1070 |
+
# Génération DOCX
|
| 1071 |
+
docx_filename = f"resume_{timestamp}.docx"
|
| 1072 |
+
docx_path = generate_docx(summary, docx_filename)
|
| 1073 |
+
|
| 1074 |
+
# Boutons de téléchargement
|
| 1075 |
+
col1, col2 = st.columns(2)
|
| 1076 |
+
with col1:
|
| 1077 |
+
with open(pdf_path, "rb") as pdf_file:
|
| 1078 |
+
st.download_button(
|
| 1079 |
+
"📥 Télécharger PDF",
|
| 1080 |
+
pdf_file,
|
| 1081 |
+
file_name=pdf_filename,
|
| 1082 |
+
mime="application/pdf",
|
| 1083 |
+
key=f"display_download_pdf_{timestamp}" # Clé unique
|
| 1084 |
+
)
|
| 1085 |
+
|
| 1086 |
+
with col2:
|
| 1087 |
+
with open(docx_path, "rb") as docx_file:
|
| 1088 |
+
st.download_button(
|
| 1089 |
+
"📥 Télécharger DOCX",
|
| 1090 |
+
docx_file,
|
| 1091 |
+
file_name=docx_filename,
|
| 1092 |
+
mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
| 1093 |
+
key=f"display_download_docx_{timestamp}" # Clé unique
|
| 1094 |
+
)
|
| 1095 |
|
| 1096 |
# Option d'envoi par email
|
| 1097 |
st.markdown("### 📧 Recevoir le résumé par email")
|
| 1098 |
+
recipient_email = st.text_input("Entrez votre adresse email:")
|
| 1099 |
|
| 1100 |
+
if st.button("Envoyer par email"):
|
| 1101 |
if not is_valid_email(recipient_email):
|
| 1102 |
st.error("Veuillez entrer une adresse email valide.")
|
| 1103 |
else:
|