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(""" # # """, unsafe_allow_html=True) # st.markdown('
Summary of the meeting
', 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()