Spaces:
Sleeping
Sleeping
File size: 2,963 Bytes
11152bc f6c931d 11152bc f6c931d 11152bc f6c931d 11152bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
import streamlit as st
from transcription import deepgram
from summary import summarize
from langchain.callbacks.base import BaseCallbackHandler
from langchain_cohere import ChatCohere
class StreamHandler(BaseCallbackHandler):
def __init__(self, container, initial_text=""):
self.container = container
self.text = initial_text
def on_llm_new_token(self, token: str, **kwargs) -> None:
self.text += token
self.container.markdown(self.text)
def main():
session_state = st.session_state
if 'transcription' not in session_state:
session_state.transcription = ""
if 'summary' not in session_state:
session_state.summary = ""
st.title("Meeting Insights")
audio_file = st.sidebar.file_uploader("Upload your audio file:")
language = st.sidebar.selectbox(
"Select Language",
("English", "French", "Spanish"))
if audio_file:
if language:
st.sidebar.audio(audio_file)
if st.sidebar.button("Generate Transcription"):
if language=="English":
session_state.transcription=deepgram(audio_file , language="en")
elif language=="French":
session_state.transcription=deepgram(audio_file,language="fr")
elif language=="Spanish":
session_state.transcription=deepgram(audio_file , language="es")
with st.container(height=500 , border=True):
st.markdown(session_state.transcription)
st.download_button('Download Transcription', session_state.transcription , file_name="Transcription.txt")
if st.sidebar.toggle("Generate Summary"):
st.header("Summary of the meeting")
with st.container(height=500):
stream_handler = StreamHandler(st.empty())
llm = ChatCohere(temperature = 0 ,streaming=True ,model = "command-r-plus" , callbacks=[stream_handler])
summarize(session_state.transcription , llm)
# import clipboard
# if st.sidebar.toggle("Generate Summary"):
# st.markdown("""
# <style>
# .big-font {
# font-size:30px !important;
# }
# </style>
# """, unsafe_allow_html=True)
# st.markdown('<p class="big-font">Summary of the meeting</p>', unsafe_allow_html=True)
# stream_handler = StreamHandler(st.empty())
# llm = ChatCohere(temperature = 0 ,streaming=True ,model = "command-r-plus" , callbacks=[stream_handler])
# data=summarize(session_state.transcription , llm)
# summary_text = data.content
# st.write(summary_text)
# copy_button = st.button("Copy Summary to Clipboard")
# if copy_button:
# clipboard.copy(summary_text)
# st.success("Summary copied to clipboard!")
if __name__ == "__main__":
main()
|