Spaces:
Sleeping
Sleeping
jobanpreet123
commited on
Upload 3 files
Browse files- app.py +48 -0
- summary.py +19 -0
- transcription.py +31 -0
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transcription import deepgram
|
3 |
+
from summary import summarize
|
4 |
+
|
5 |
+
|
6 |
+
def main():
|
7 |
+
session_state = st.session_state
|
8 |
+
|
9 |
+
if 'transcription' not in session_state:
|
10 |
+
session_state.transcription = ""
|
11 |
+
if "summary" not in session_state:
|
12 |
+
session_state.summary=""
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
st.title("Meeting Insights")
|
17 |
+
|
18 |
+
|
19 |
+
audio_file = st.sidebar.file_uploader("Upload your audio file:")
|
20 |
+
|
21 |
+
language = st.sidebar.selectbox(
|
22 |
+
"Select Language",
|
23 |
+
("English", "French", "Spanish"))
|
24 |
+
if audio_file:
|
25 |
+
if language:
|
26 |
+
st.sidebar.audio(audio_file)
|
27 |
+
if st.sidebar.button("Generate Transcription"):
|
28 |
+
if language=="English":
|
29 |
+
session_state.transcription=deepgram(audio_file , language="en")
|
30 |
+
elif language=="French":
|
31 |
+
session_state.transcription=deepgram(audio_file,language="fr")
|
32 |
+
elif language=="Spanish":
|
33 |
+
session_state.transcription=deepgram(audio_file , language="es")
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
transcription=st.text_area("Transcription",value=session_state.transcription, height=400)
|
39 |
+
if transcription:
|
40 |
+
st.download_button('Download Transcription', session_state.transcription , file_name="Transcription.txt")
|
41 |
+
if st.sidebar.toggle("Generate Summary"):
|
42 |
+
session_state.summary=summarize(session_state.transcription)
|
43 |
+
st.text_area("Summary" , value=session_state.summary , height=400)
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
main()
|
47 |
+
|
48 |
+
|
summary.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from langchain_groq import ChatGroq
|
2 |
+
from langchain.prompts import ChatPromptTemplate
|
3 |
+
from langchain_core.output_parsers import StrOutputParser
|
4 |
+
from dotenv import load_dotenv
|
5 |
+
|
6 |
+
load_dotenv()
|
7 |
+
|
8 |
+
model = ChatGroq(temperature=0, model_name="mixtral-8x7b-32768") #mixtral-8x7b-32768
|
9 |
+
|
10 |
+
|
11 |
+
def summarize(transcription):
|
12 |
+
template="""You are provided with transcription of a meeting between different people. Your task is to summarize this transcription
|
13 |
+
Transcription: {transcription}"""
|
14 |
+
|
15 |
+
prompt = ChatPromptTemplate.from_template(template)
|
16 |
+
|
17 |
+
chain = prompt | model | StrOutputParser()
|
18 |
+
summary=chain.invoke({"transcription":transcription})
|
19 |
+
return summary
|
transcription.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DEEPGRAM_API_KEY = "133b94c2e717ad8749463de64418ba5fb78efcb3"
|
2 |
+
|
3 |
+
|
4 |
+
from deepgram import (
|
5 |
+
DeepgramClient,
|
6 |
+
PrerecordedOptions,
|
7 |
+
FileSource
|
8 |
+
)
|
9 |
+
import httpx
|
10 |
+
def deepgram(buffer_data,language):
|
11 |
+
# STEP 1 Create a Deepgram client using the API key
|
12 |
+
deepgram = DeepgramClient(DEEPGRAM_API_KEY)
|
13 |
+
|
14 |
+
payload: FileSource = {
|
15 |
+
"buffer": buffer_data,
|
16 |
+
}
|
17 |
+
|
18 |
+
#STEP 2: Configure Deepgram options for audio analysis
|
19 |
+
options = PrerecordedOptions(
|
20 |
+
model="nova-2",
|
21 |
+
smart_format=True,
|
22 |
+
language=language,
|
23 |
+
diarize=True,
|
24 |
+
|
25 |
+
|
26 |
+
)
|
27 |
+
myTimeout = httpx.Timeout(300, connect=10.0)
|
28 |
+
# STEP 3: Call the transcribe_file method with the text payload and options
|
29 |
+
response = deepgram.listen.prerecorded.v("1").transcribe_file(payload, options,timeout=myTimeout)
|
30 |
+
text=response['results']['channels'][0]['alternatives'][0]['paragraphs']['transcript']
|
31 |
+
return text
|