Update app.py
Browse files
app.py
CHANGED
|
@@ -178,6 +178,10 @@ def transcribe_and_diarize(file_path, task, progress=gr.Progress()):
|
|
| 178 |
return "Transcription terminée!", transcription_result['text'], speaker_transcription
|
| 179 |
|
| 180 |
def format_to_markdown(transcription_text, speaker_transcription, audio_duration=None, location=None, speaker_age=None, context=None, num_speakers=None, speaker_names=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
metadata = {
|
| 182 |
"Date de traitement": datetime.now().strftime('%d/%m/%Y %H:%M'),
|
| 183 |
"Durée de l'audio": f"{audio_duration}" if audio_duration else "[à remplir]",
|
|
@@ -199,15 +203,20 @@ def format_to_markdown(transcription_text, speaker_transcription, audio_duration
|
|
| 199 |
elif isinstance(row, (list, tuple)) and len(row) == 2:
|
| 200 |
custom_names[row[0]] = row[1]
|
| 201 |
|
|
|
|
|
|
|
| 202 |
metadata_text = "\n".join([f"- **{key}** : '{value}'" for key, value in metadata.items()])
|
| 203 |
|
| 204 |
try:
|
| 205 |
if isinstance(speaker_transcription, str):
|
| 206 |
speaker_transcription = parse_simplified_diarization(speaker_transcription)
|
| 207 |
|
|
|
|
|
|
|
| 208 |
formatted_transcription = []
|
| 209 |
for speaker, text in speaker_transcription:
|
| 210 |
custom_name = custom_names.get(speaker, speaker)
|
|
|
|
| 211 |
formatted_transcription.append(f"**{custom_name}**: {text}")
|
| 212 |
transcription_text = "\n\n".join(formatted_transcription)
|
| 213 |
except Exception as e:
|
|
@@ -223,6 +232,7 @@ def format_to_markdown(transcription_text, speaker_transcription, audio_duration
|
|
| 223 |
## Transcription
|
| 224 |
{transcription_text}
|
| 225 |
"""
|
|
|
|
| 226 |
return formatted_output
|
| 227 |
|
| 228 |
def _return_yt_html_embed(yt_url):
|
|
|
|
| 178 |
return "Transcription terminée!", transcription_result['text'], speaker_transcription
|
| 179 |
|
| 180 |
def format_to_markdown(transcription_text, speaker_transcription, audio_duration=None, location=None, speaker_age=None, context=None, num_speakers=None, speaker_names=None):
|
| 181 |
+
print("Début de format_to_markdown")
|
| 182 |
+
print("speaker_names reçu :", speaker_names)
|
| 183 |
+
print("num_speakers reçu :", num_speakers)
|
| 184 |
+
|
| 185 |
metadata = {
|
| 186 |
"Date de traitement": datetime.now().strftime('%d/%m/%Y %H:%M'),
|
| 187 |
"Durée de l'audio": f"{audio_duration}" if audio_duration else "[à remplir]",
|
|
|
|
| 203 |
elif isinstance(row, (list, tuple)) and len(row) == 2:
|
| 204 |
custom_names[row[0]] = row[1]
|
| 205 |
|
| 206 |
+
print("custom_names créé :", custom_names)
|
| 207 |
+
|
| 208 |
metadata_text = "\n".join([f"- **{key}** : '{value}'" for key, value in metadata.items()])
|
| 209 |
|
| 210 |
try:
|
| 211 |
if isinstance(speaker_transcription, str):
|
| 212 |
speaker_transcription = parse_simplified_diarization(speaker_transcription)
|
| 213 |
|
| 214 |
+
print("speaker_transcription après parsing :", speaker_transcription)
|
| 215 |
+
|
| 216 |
formatted_transcription = []
|
| 217 |
for speaker, text in speaker_transcription:
|
| 218 |
custom_name = custom_names.get(speaker, speaker)
|
| 219 |
+
print(f"Utilisation du nom : {custom_name} pour le speaker : {speaker}")
|
| 220 |
formatted_transcription.append(f"**{custom_name}**: {text}")
|
| 221 |
transcription_text = "\n\n".join(formatted_transcription)
|
| 222 |
except Exception as e:
|
|
|
|
| 232 |
## Transcription
|
| 233 |
{transcription_text}
|
| 234 |
"""
|
| 235 |
+
print("Fin de format_to_markdown")
|
| 236 |
return formatted_output
|
| 237 |
|
| 238 |
def _return_yt_html_embed(yt_url):
|