Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import os
|
|
8 |
|
9 |
@st.cache_resource
|
10 |
def load_models():
|
11 |
-
whisper_model = whisper.load_model("base")
|
12 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
13 |
nlp = spacy.load("en_core_web_sm")
|
14 |
return whisper_model, summarizer, nlp
|
@@ -41,19 +41,28 @@ def main():
|
|
41 |
|
42 |
whisper_model, summarizer, nlp = load_models()
|
43 |
|
44 |
-
audio_file = st.file_uploader("Upload meeting audio", type=["wav", "mp3", "m4a"])
|
45 |
|
46 |
if audio_file is not None:
|
47 |
-
file_path = f"uploaded_audio_{datetime.datetime.now().timestamp()}"
|
|
|
|
|
48 |
with open(file_path, "wb") as f:
|
49 |
f.write(audio_file.getbuffer())
|
50 |
-
|
51 |
st.subheader("Meeting Transcription")
|
52 |
with st.spinner("Transcribing audio..."):
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
result = whisper_model.transcribe(file_path)
|
54 |
transcript = result["text"]
|
|
|
55 |
st.write(transcript)
|
56 |
-
os.remove(file_path)
|
57 |
|
58 |
st.subheader("Meeting Summary")
|
59 |
with st.spinner("Generating summary..."):
|
@@ -78,10 +87,9 @@ def main():
|
|
78 |
""")
|
79 |
|
80 |
st.subheader("π Key Terms")
|
81 |
-
# Fixed keyword processing
|
82 |
key_phrases_result = keywords.keywords(transcript) or ""
|
83 |
key_phrases = [kp.strip() for kp in key_phrases_result.split("\n") if kp.strip()]
|
84 |
st.write(", ".join(key_phrases) if key_phrases else "No key terms extracted")
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
-
main()
|
|
|
8 |
|
9 |
@st.cache_resource
|
10 |
def load_models():
|
11 |
+
whisper_model = whisper.load_model("base") # You can use 'small' or 'medium' for better results
|
12 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
13 |
nlp = spacy.load("en_core_web_sm")
|
14 |
return whisper_model, summarizer, nlp
|
|
|
41 |
|
42 |
whisper_model, summarizer, nlp = load_models()
|
43 |
|
44 |
+
audio_file = st.file_uploader("Upload meeting audio", type=["wav", "mp3", "m4a", "ogg", "flac"])
|
45 |
|
46 |
if audio_file is not None:
|
47 |
+
file_path = f"uploaded_audio_{datetime.datetime.now().timestamp()}.wav"
|
48 |
+
|
49 |
+
# Save uploaded file
|
50 |
with open(file_path, "wb") as f:
|
51 |
f.write(audio_file.getbuffer())
|
52 |
+
|
53 |
st.subheader("Meeting Transcription")
|
54 |
with st.spinner("Transcribing audio..."):
|
55 |
+
# Load and process audio
|
56 |
+
audio = whisper.load_audio(file_path) # Converts to 16kHz mono
|
57 |
+
audio = whisper.pad_or_trim(audio) # Ensures proper input size
|
58 |
+
mel = whisper.log_mel_spectrogram(audio).to(whisper_model.device)
|
59 |
+
|
60 |
+
# Transcribe
|
61 |
result = whisper_model.transcribe(file_path)
|
62 |
transcript = result["text"]
|
63 |
+
|
64 |
st.write(transcript)
|
65 |
+
os.remove(file_path) # Cleanup
|
66 |
|
67 |
st.subheader("Meeting Summary")
|
68 |
with st.spinner("Generating summary..."):
|
|
|
87 |
""")
|
88 |
|
89 |
st.subheader("π Key Terms")
|
|
|
90 |
key_phrases_result = keywords.keywords(transcript) or ""
|
91 |
key_phrases = [kp.strip() for kp in key_phrases_result.split("\n") if kp.strip()]
|
92 |
st.write(", ".join(key_phrases) if key_phrases else "No key terms extracted")
|
93 |
|
94 |
if __name__ == "__main__":
|
95 |
+
main()
|