Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,7 +53,6 @@ def transcribe_audio(audio_path):
|
|
| 53 |
return "Aucun fichier audio fourni", None, [], "", ""
|
| 54 |
|
| 55 |
file_name = os.path.basename(audio_path).rsplit('.', 1)[0] # Extraire le nom sans extension
|
| 56 |
-
zip_name = file_name
|
| 57 |
result = pipe(audio_path, return_timestamps="word")
|
| 58 |
words = result.get("chunks", [])
|
| 59 |
|
|
@@ -64,7 +63,7 @@ def transcribe_audio(audio_path):
|
|
| 64 |
word_timestamps = [(w["text"], w["timestamp"][0], w["timestamp"][1]) for w in words]
|
| 65 |
transcription_with_timestamps = " ".join([f"{w[0]}[{w[1]:.2f}-{w[2]:.2f}]" for w in word_timestamps])
|
| 66 |
|
| 67 |
-
return raw_transcription, word_timestamps, transcription_with_timestamps, audio_path, file_name
|
| 68 |
if not audio_path:
|
| 69 |
return "Aucun fichier audio fourni", None, [], ""
|
| 70 |
|
|
@@ -169,7 +168,7 @@ def generate_zip(metadata_state, audio_path, zip_name):
|
|
| 169 |
with gr.Blocks() as demo:
|
| 170 |
gr.Markdown("# Application de Découpe Audio")
|
| 171 |
metadata_state = gr.State(init_metadata_state())
|
| 172 |
-
|
| 173 |
zip_name = gr.Textbox(label="Nom du fichier ZIP", interactive=True)
|
| 174 |
raw_transcription = gr.Textbox(label="Transcription", interactive=True)
|
| 175 |
transcription_timestamps = gr.Textbox(label="Transcription avec Timestamps", interactive=True)
|
|
@@ -178,8 +177,8 @@ with gr.Blocks() as demo:
|
|
| 178 |
generate_button = gr.Button("Générer ZIP")
|
| 179 |
zip_file = gr.File(label="Télécharger le ZIP")
|
| 180 |
|
| 181 |
-
audio_input.change(transcribe_audio, inputs=
|
| 182 |
save_button.click(save_segments, inputs=[table, zip_name], outputs=[metadata_state, zip_name])
|
| 183 |
-
generate_button.click(generate_zip, inputs=[metadata_state,
|
| 184 |
|
| 185 |
demo.queue().launch()
|
|
|
|
| 53 |
return "Aucun fichier audio fourni", None, [], "", ""
|
| 54 |
|
| 55 |
file_name = os.path.basename(audio_path).rsplit('.', 1)[0] # Extraire le nom sans extension
|
|
|
|
| 56 |
result = pipe(audio_path, return_timestamps="word")
|
| 57 |
words = result.get("chunks", [])
|
| 58 |
|
|
|
|
| 63 |
word_timestamps = [(w["text"], w["timestamp"][0], w["timestamp"][1]) for w in words]
|
| 64 |
transcription_with_timestamps = " ".join([f"{w[0]}[{w[1]:.2f}-{w[2]:.2f}]" for w in word_timestamps])
|
| 65 |
|
| 66 |
+
return raw_transcription, word_timestamps, transcription_with_timestamps, audio_path, file_name
|
| 67 |
if not audio_path:
|
| 68 |
return "Aucun fichier audio fourni", None, [], ""
|
| 69 |
|
|
|
|
| 168 |
with gr.Blocks() as demo:
|
| 169 |
gr.Markdown("# Application de Découpe Audio")
|
| 170 |
metadata_state = gr.State(init_metadata_state())
|
| 171 |
+
zip_name = gr.Audio(type="filepath", label="Fichier audio")
|
| 172 |
zip_name = gr.Textbox(label="Nom du fichier ZIP", interactive=True)
|
| 173 |
raw_transcription = gr.Textbox(label="Transcription", interactive=True)
|
| 174 |
transcription_timestamps = gr.Textbox(label="Transcription avec Timestamps", interactive=True)
|
|
|
|
| 177 |
generate_button = gr.Button("Générer ZIP")
|
| 178 |
zip_file = gr.File(label="Télécharger le ZIP")
|
| 179 |
|
| 180 |
+
audio_input.change(transcribe_audio, inputs=zip_name, outputs=[raw_transcription, transcription_timestamps, zip_name])
|
| 181 |
save_button.click(save_segments, inputs=[table, zip_name], outputs=[metadata_state, zip_name])
|
| 182 |
+
generate_button.click(generate_zip, inputs=[metadata_state, zip_name], outputs=zip_file)
|
| 183 |
|
| 184 |
demo.queue().launch()
|