Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,7 @@ def format_time(milliseconds):
|
|
28 |
minutes, seconds = divmod(seconds, 60)
|
29 |
return f"{int(hours):02}:{int(minutes):02}:{int(seconds):02}"
|
30 |
|
31 |
-
def
|
32 |
speaker_label_pattern = r"^(.+?)(?=\s\d{2}:\d{2}:\d{2})"
|
33 |
timestamp_pattern = r"(\d{2}:\d{2}:\d{2})"
|
34 |
formatted_transcript = re.sub(
|
@@ -50,14 +50,14 @@ def transcribe_audio(audio_file):
|
|
50 |
return f"An error occurred: {transcript.error}", None
|
51 |
|
52 |
transcript_string = transcript_to_string(transcript)
|
53 |
-
md_transcript =
|
54 |
|
55 |
# Save the markdown transcript to a temporary file
|
56 |
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.md') as temp_file:
|
57 |
temp_file.write(md_transcript)
|
58 |
temp_file_path = temp_file.name
|
59 |
|
60 |
-
return
|
61 |
except Exception as e:
|
62 |
return f"An error occurred: {str(e)}", None
|
63 |
|
@@ -67,10 +67,10 @@ def launch_app():
|
|
67 |
inputs=gr.Audio(type="filepath", label="Upload Audio File"),
|
68 |
outputs=[
|
69 |
gr.Textbox(label="Transcript Preview", lines=10),
|
70 |
-
gr.File(label="Download Transcript")
|
71 |
],
|
72 |
title="Audio Transcription App",
|
73 |
-
description="Upload an audio file to get a transcription with speaker labels."
|
74 |
)
|
75 |
iface.launch()
|
76 |
|
|
|
28 |
minutes, seconds = divmod(seconds, 60)
|
29 |
return f"{int(hours):02}:{int(minutes):02}:{int(seconds):02}"
|
30 |
|
31 |
+
def format_transcript_markdown(transcript_string):
|
32 |
speaker_label_pattern = r"^(.+?)(?=\s\d{2}:\d{2}:\d{2})"
|
33 |
timestamp_pattern = r"(\d{2}:\d{2}:\d{2})"
|
34 |
formatted_transcript = re.sub(
|
|
|
50 |
return f"An error occurred: {transcript.error}", None
|
51 |
|
52 |
transcript_string = transcript_to_string(transcript)
|
53 |
+
md_transcript = format_transcript_markdown(transcript_string)
|
54 |
|
55 |
# Save the markdown transcript to a temporary file
|
56 |
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.md') as temp_file:
|
57 |
temp_file.write(md_transcript)
|
58 |
temp_file_path = temp_file.name
|
59 |
|
60 |
+
return transcript_string, temp_file_path
|
61 |
except Exception as e:
|
62 |
return f"An error occurred: {str(e)}", None
|
63 |
|
|
|
67 |
inputs=gr.Audio(type="filepath", label="Upload Audio File"),
|
68 |
outputs=[
|
69 |
gr.Textbox(label="Transcript Preview", lines=10),
|
70 |
+
gr.File(label="Download Formatted Transcript")
|
71 |
],
|
72 |
title="Audio Transcription App",
|
73 |
+
description="Upload an audio file to get a transcription with speaker labels. The preview shows plain text, while the download includes markdown formatting."
|
74 |
)
|
75 |
iface.launch()
|
76 |
|