Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,9 @@ from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
|
6 |
processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
|
7 |
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
|
8 |
|
|
|
|
|
|
|
9 |
# Sidebar for file upload
|
10 |
st.sidebar.title("Upload your audio file")
|
11 |
uploaded_file = st.sidebar.file_uploader("Choose an audio file", type=["mp3", "wav", "mp4", "m4a"])
|
@@ -21,8 +24,6 @@ if uploaded_file:
|
|
21 |
segment_duration = 120 # Segment duration in seconds (2 minutes)
|
22 |
num_segments = len(resampled_waveform[0]) // (segment_duration * 16000)
|
23 |
segment_transcriptions = []
|
24 |
-
current_speaker = None
|
25 |
-
current_paragraph = ""
|
26 |
|
27 |
# Transcribe each segment
|
28 |
for i in range(num_segments):
|
@@ -43,21 +44,7 @@ if uploaded_file:
|
|
43 |
# Combine segment transcriptions into the full transcript
|
44 |
full_transcript = " ".join(segment_transcriptions)
|
45 |
|
46 |
-
# Separate transcript by speakers and apply paragraphs
|
47 |
-
for line in full_transcript.split('. '): # You can adjust the separator depending on your audio content
|
48 |
-
if line.endswith((':', 'said')):
|
49 |
-
if current_paragraph:
|
50 |
-
st.write(f"Speaker: {current_speaker}")
|
51 |
-
st.write(current_paragraph + ".")
|
52 |
-
current_speaker = line
|
53 |
-
current_paragraph = ""
|
54 |
-
else:
|
55 |
-
current_paragraph += line + ". "
|
56 |
-
# Adding the last speaker paragraph
|
57 |
-
if current_paragraph:
|
58 |
-
st.write(f"Speaker: {current_speaker}")
|
59 |
-
st.write(current_paragraph + ".")
|
60 |
-
|
61 |
# Display the transcript
|
62 |
st.header("Transcription")
|
63 |
-
st.write(full_transcript)
|
|
|
|
6 |
processor = WhisperProcessor.from_pretrained("openai/whisper-tiny.en")
|
7 |
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-tiny.en")
|
8 |
|
9 |
+
# Title
|
10 |
+
st.title('Audio to Text Transcription')
|
11 |
+
|
12 |
# Sidebar for file upload
|
13 |
st.sidebar.title("Upload your audio file")
|
14 |
uploaded_file = st.sidebar.file_uploader("Choose an audio file", type=["mp3", "wav", "mp4", "m4a"])
|
|
|
24 |
segment_duration = 120 # Segment duration in seconds (2 minutes)
|
25 |
num_segments = len(resampled_waveform[0]) // (segment_duration * 16000)
|
26 |
segment_transcriptions = []
|
|
|
|
|
27 |
|
28 |
# Transcribe each segment
|
29 |
for i in range(num_segments):
|
|
|
44 |
# Combine segment transcriptions into the full transcript
|
45 |
full_transcript = " ".join(segment_transcriptions)
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# Display the transcript
|
48 |
st.header("Transcription")
|
49 |
+
st.write(full_transcript)
|
50 |
+
|