vsrinivas commited on
Commit
034d51f
·
verified ·
1 Parent(s): 5d4e153

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -14
app.py CHANGED
@@ -33,12 +33,12 @@ language_codes = {"English":"en", "Hindi":"hi", "Portuguese":"pt", "Chinese":"zh
33
  "Ukrainian":"uk", "Greek":"el", "Czech":"cs", "Danish":"da", "Finnish":"fi",
34
  "Bulgarian":"bg", "Croatian":"hr", "Slovak":"sk"}
35
 
36
- meeting_texts = []
37
  n_participants = 4 # This can be adjusted based on the number of people in the call
38
  language_choices = ["English", "Polish", "Hindi", "Arabic"]
39
 
40
  def clear_all():
41
- global meeting_texts
42
  meeting_texts = [] # Reset meeting texts
43
  return [None] * (n_participants * 4 + 1) # Reset outputs of transcripts, translated texts, and dubbed videos
44
 
@@ -136,20 +136,17 @@ def create_dub_from_file(
136
  return None
137
 
138
 
139
- def summarize(meeting_texts=meeting_texts):
140
  mt = ', '.join([f"{k}: {v}" for i in meeting_texts for k, v in i.items()])
141
  meeting_date_time = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
142
  meeting_texts = meeting_date_time + '\n' + mt
143
 
144
- # meeting_conversation_processed ='\n'.join(mt)
145
- # print("M:", session_conversation_processed)
146
-
147
  minutes_of_meeting = ""
148
  for chunk in AI71(AI71_API_KEY.strip()).chat.completions.create(
149
  model="tiiuae/falcon-180b-chat",
150
  messages=[
151
  {"role": "system", "content": f"""You are an expereiced Secretary who can summarize meeting discussions into minutes of meeting.
152
- Summarize the meetings discussions provided as Speakerwise conversation.
153
  Strictly consider only the context given in user content {meeting_texts} for summarization.
154
  Ensure to mention the title as 'Minutes of Meeting held on {meeting_date_time} and present the summary with better viewing format and title in bold letters"""},
155
  {"role": "user", "content": meeting_texts},
@@ -198,12 +195,12 @@ def synthesize_speech(video, source_language,target_language):
198
  return dub_video
199
 
200
  # This function handles the processing when any participant speaks
201
- def process_speaker(video, speaker_idx, n_participants, *language_list):
202
  transcript = speech_to_text(video)
203
 
204
  # Create outputs for each participant
205
  outputs = []
206
- global meeting_texts
207
  def process_translation_dubbing(i):
208
  if i != speaker_idx:
209
  participant_language = language_codes[language_list[i]]
@@ -223,6 +220,7 @@ def process_speaker(video, speaker_idx, n_participants, *language_list):
223
  else:
224
  outputs.append(translated_text)
225
  outputs.append(dubbed_video)
 
226
  if speaker_idx == 0:
227
  meeting_texts.append({f"Speaker_{speaker_idx+1}":outputs[0]})
228
  else:
@@ -230,9 +228,11 @@ def process_speaker(video, speaker_idx, n_participants, *language_list):
230
 
231
  print(len(outputs))
232
  print(outputs)
 
233
  print('meeting_texts: ',meeting_texts)
234
  return outputs
235
 
 
236
  def create_participant_row(i, language_choices):
237
  """Creates the UI for a single participant."""
238
  with gr.Row():
@@ -243,12 +243,15 @@ def create_participant_row(i, language_choices):
243
  dubbed_video = gr.Video(label="Speaker's Dubbed Video")
244
  return video_input, language_dropdown, transcript_output, translated_text, dubbed_video
245
 
 
246
  # Main dynamic Gradio interface
247
  def create_gradio_interface(n_participants, language_choices):
248
  with gr.Blocks() as demo:
249
  gr.Markdown("""# LinguaPolis: Bridging Languages, Uniting Teams Globally - Multilingual Conference Call Simulation
250
  ## Record your video or upload your video and press the corresponding Submit button at the bottom""")
251
 
 
 
252
  video_inputs = []
253
  language_dropdowns = []
254
  transcript_outputs = []
@@ -256,7 +259,7 @@ def create_gradio_interface(n_participants, language_choices):
256
  dubbed_videos = []
257
 
258
  clear_button = gr.Button("Clear All")
259
-
260
  # Create a row for each participant
261
  for i in range(n_participants):
262
  video_input, language_dropdown, transcript_output, translated_text, dubbed_video = create_participant_row(i, language_choices)
@@ -270,12 +273,13 @@ def create_gradio_interface(n_participants, language_choices):
270
  for i in range(n_participants):
271
  gr.Button(f"Submit Speaker {i+1}'s Speech").click(
272
  process_speaker,
273
- [video_inputs[i], gr.State(i), gr.State(n_participants)] + [language_dropdowns[j] for j in range(n_participants)],
274
- [transcript_outputs[i]] + [k for j in zip(translated_texts[:i]+translated_texts[i+1:], dubbed_videos[:i]+dubbed_videos[i+1:]) for k in j]
 
275
  )
276
  minutes = gr.Textbox(label="Minutes of Meeting")
277
- gr.Button(f"Generate Minutes of meeting").click(summarize, None, minutes)
278
-
279
  # Clear button to reset inputs and outputs
280
  clear_button.click(clear_all, None, [*video_inputs, *transcript_outputs, *translated_texts, *dubbed_videos, minutes])
281
 
 
33
  "Ukrainian":"uk", "Greek":"el", "Czech":"cs", "Danish":"da", "Finnish":"fi",
34
  "Bulgarian":"bg", "Croatian":"hr", "Slovak":"sk"}
35
 
36
+ # meeting_texts = []
37
  n_participants = 4 # This can be adjusted based on the number of people in the call
38
  language_choices = ["English", "Polish", "Hindi", "Arabic"]
39
 
40
  def clear_all():
41
+ # global meeting_texts
42
  meeting_texts = [] # Reset meeting texts
43
  return [None] * (n_participants * 4 + 1) # Reset outputs of transcripts, translated texts, and dubbed videos
44
 
 
136
  return None
137
 
138
 
139
+ def summarize(meeting_texts):
140
  mt = ', '.join([f"{k}: {v}" for i in meeting_texts for k, v in i.items()])
141
  meeting_date_time = str(datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
142
  meeting_texts = meeting_date_time + '\n' + mt
143
 
 
 
 
144
  minutes_of_meeting = ""
145
  for chunk in AI71(AI71_API_KEY.strip()).chat.completions.create(
146
  model="tiiuae/falcon-180b-chat",
147
  messages=[
148
  {"role": "system", "content": f"""You are an expereiced Secretary who can summarize meeting discussions into minutes of meeting.
149
+ Summarize the meetings discussions provided as Speakerwise conversation.
150
  Strictly consider only the context given in user content {meeting_texts} for summarization.
151
  Ensure to mention the title as 'Minutes of Meeting held on {meeting_date_time} and present the summary with better viewing format and title in bold letters"""},
152
  {"role": "user", "content": meeting_texts},
 
195
  return dub_video
196
 
197
  # This function handles the processing when any participant speaks
198
+ def process_speaker(video, speaker_idx, n_participants, meeting_texts, *language_list):
199
  transcript = speech_to_text(video)
200
 
201
  # Create outputs for each participant
202
  outputs = []
203
+ # global meeting_texts
204
  def process_translation_dubbing(i):
205
  if i != speaker_idx:
206
  participant_language = language_codes[language_list[i]]
 
220
  else:
221
  outputs.append(translated_text)
222
  outputs.append(dubbed_video)
223
+
224
  if speaker_idx == 0:
225
  meeting_texts.append({f"Speaker_{speaker_idx+1}":outputs[0]})
226
  else:
 
228
 
229
  print(len(outputs))
230
  print(outputs)
231
+ outputs.extend(meeting_texts)
232
  print('meeting_texts: ',meeting_texts)
233
  return outputs
234
 
235
+
236
  def create_participant_row(i, language_choices):
237
  """Creates the UI for a single participant."""
238
  with gr.Row():
 
243
  dubbed_video = gr.Video(label="Speaker's Dubbed Video")
244
  return video_input, language_dropdown, transcript_output, translated_text, dubbed_video
245
 
246
+
247
  # Main dynamic Gradio interface
248
  def create_gradio_interface(n_participants, language_choices):
249
  with gr.Blocks() as demo:
250
  gr.Markdown("""# LinguaPolis: Bridging Languages, Uniting Teams Globally - Multilingual Conference Call Simulation
251
  ## Record your video or upload your video and press the corresponding Submit button at the bottom""")
252
 
253
+ meeting_texts = []
254
+
255
  video_inputs = []
256
  language_dropdowns = []
257
  transcript_outputs = []
 
259
  dubbed_videos = []
260
 
261
  clear_button = gr.Button("Clear All")
262
+
263
  # Create a row for each participant
264
  for i in range(n_participants):
265
  video_input, language_dropdown, transcript_output, translated_text, dubbed_video = create_participant_row(i, language_choices)
 
273
  for i in range(n_participants):
274
  gr.Button(f"Submit Speaker {i+1}'s Speech").click(
275
  process_speaker,
276
+ # [video_inputs[i], gr.State(i), gr.State(n_participants)] + [language_dropdowns[j] for j in range(n_participants)],
277
+ [video_inputs[i], gr.State(i), gr.State(n_participants)] + [gr.State(meeting_texts)] + [language_dropdowns[j] for j in range(n_participants)],
278
+ [transcript_outputs[i]] + [k for j in zip(translated_texts[:i]+translated_texts[i+1:], dubbed_videos[:i]+dubbed_videos[i+1:]) for k in j] + [gr.State(meeting_texts)]
279
  )
280
  minutes = gr.Textbox(label="Minutes of Meeting")
281
+ gr.Button(f"Generate Minutes of meeting").click(summarize, meeting_texts, minutes)
282
+
283
  # Clear button to reset inputs and outputs
284
  clear_button.click(clear_all, None, [*video_inputs, *transcript_outputs, *translated_texts, *dubbed_videos, minutes])
285