Vijayanand Sankarasubramanian commited on
Commit
0dbead4
·
1 Parent(s): 1c0a23b

fix for UI

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -5,6 +5,8 @@ from helpers.model_utils import get_model
5
  from aspect_and_sentiment_extraction import extract_aspects_and_sentiment
6
  from answer_bot import answer_question
7
 
 
 
8
  def summarize(transcript_file_name):
9
  chunked_docs = load_rtf_document_and_chunk(transcript_file_name)
10
 
@@ -15,7 +17,11 @@ def extract_aspects(transcript_file_name):
15
  # Implement your aspect extraction and sentiment analysis logic here
16
  return extract_aspects_and_sentiment(transcript_file_name)
17
 
 
18
  def get_answer_for(user_question):
 
 
 
19
  # Answer the user's question using the question-answering model
20
  if user_question.strip(): # Ensure there is a question provided
21
  answer_text = answer_question(question=user_question)
@@ -25,9 +31,8 @@ def get_answer_for(user_question):
25
  return answer_text.lstrip()
26
 
27
  def process_transcript(uploaded_file):
28
- # Process the file
29
- transcript_file_name = uploaded_file.name
30
- print(f"Transcript File Name :{transcript_file_name}")
31
 
32
  # Summarize the content
33
  summary = summarize(transcript_file_name=transcript_file_name).lstrip()
@@ -37,15 +42,23 @@ def process_transcript(uploaded_file):
37
 
38
  return summary, sentiment
39
 
 
 
 
 
40
  with gr.Blocks() as demo:
41
- with gr.Tab("Aspect/Sentiment"):
42
  rtf_file = gr.File(label="Podcast Transcript RTF file")
 
 
 
43
  summary = gr.Textbox(label="Summary of Podcast")
44
  sentiment = gr.Textbox(label="Aspect Based Sentiments")
45
- submit_button = gr.Button("Submit")
46
- submit_button.click(process_transcript, inputs=rtf_file, outputs=[summary, sentiment])
47
-
48
- with gr.Tab("Question/Answer"):
 
49
  question = gr.Textbox(label="Question")
50
  answer = gr.Textbox(label="Answer")
51
  answer_button = gr.Button("Answer Question")
 
5
  from aspect_and_sentiment_extraction import extract_aspects_and_sentiment
6
  from answer_bot import answer_question
7
 
8
+ transcript_file_name = None
9
+
10
  def summarize(transcript_file_name):
11
  chunked_docs = load_rtf_document_and_chunk(transcript_file_name)
12
 
 
17
  # Implement your aspect extraction and sentiment analysis logic here
18
  return extract_aspects_and_sentiment(transcript_file_name)
19
 
20
+
21
  def get_answer_for(user_question):
22
+ if transcript_file_name is None:
23
+ return "No Transcript Uploaded, Upload RTF File First", ""
24
+
25
  # Answer the user's question using the question-answering model
26
  if user_question.strip(): # Ensure there is a question provided
27
  answer_text = answer_question(question=user_question)
 
31
  return answer_text.lstrip()
32
 
33
  def process_transcript(uploaded_file):
34
+ if transcript_file_name is None:
35
+ return "No Transcript Uploaded, Upload RTF File First", ""
 
36
 
37
  # Summarize the content
38
  summary = summarize(transcript_file_name=transcript_file_name).lstrip()
 
42
 
43
  return summary, sentiment
44
 
45
+ def setup_rtf_file_handle(uploaded_file):
46
+ transcript_file_name = uploaded_file.name
47
+ print(f"Transcript File Name :{transcript_file_name}")
48
+
49
  with gr.Blocks() as demo:
50
+ with gr.Group("Upload RTF File"):
51
  rtf_file = gr.File(label="Podcast Transcript RTF file")
52
+ submit_button = gr.Button("Upload File")
53
+ submit_button.click(setup_rtf_file_handle)
54
+ with gr.Group("Aspects and Sentiment of Podcast"):
55
  summary = gr.Textbox(label="Summary of Podcast")
56
  sentiment = gr.Textbox(label="Aspect Based Sentiments")
57
+ submit_button = gr.Button("Generate Aspects and Summary")
58
+ submit_button.click(process_transcript, inputs=rtf_file, outputs=[summary, sentiment])
59
+
60
+ with gr.Group("Question/Answer"):
61
+ gr.Markdown("Question/Answer")
62
  question = gr.Textbox(label="Question")
63
  answer = gr.Textbox(label="Answer")
64
  answer_button = gr.Button("Answer Question")