remotewith commited on
Commit
4ace62c
1 Parent(s): df057cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -24,6 +24,8 @@ embedding_model = PretrainedSpeakerEmbedding(
24
  "speechbrain/spkrec-ecapa-voxceleb",
25
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
26
  )
 
 
27
  ######################################################
28
  def audio_to_text(audio, num_speakers):
29
  path, error = convert_to_wav(audio)
@@ -44,9 +46,9 @@ def audio_to_text(audio, num_speakers):
44
  else:
45
  embeddings = make_embeddings(path, segments, duration)
46
  add_speaker_labels(segments, embeddings, num_speakers)
47
- output = get_output(segments)
48
  short_sum=text_to_short_summary(str(output))
49
- return output , short_sum
50
 
51
  def convert_to_wav(path):
52
  if path[-3:] != 'wav':
@@ -103,13 +105,13 @@ def get_output(segments):
103
  #########################################################################
104
 
105
 
106
- def text_to_short_summary(text):
107
 
108
  from transformers import pipeline
109
  summarizer = pipeline("summarization", model="knkarthick/MEETING-SUMMARY-BART-LARGE-XSUM-SAMSUM-DIALOGSUM")
110
  #text = '''The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.
111
  #'''
112
- return summarizer(text)
113
 
114
  ###########################################################################
115
 
@@ -123,15 +125,19 @@ app1=gr.Interface(
123
 
124
  ],
125
  outputs=[
126
- (gr.outputs.Textbox(label='Transcript')),
127
- (gr.outputs.Textbox(label='Short_summary'))
128
 
129
  ]
130
  )
131
 
 
 
 
 
132
 
 
133
 
134
- app1.launch()
135
 
136
 
137
 
 
24
  "speechbrain/spkrec-ecapa-voxceleb",
25
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
26
  )
27
+
28
+ output=""
29
  ######################################################
30
  def audio_to_text(audio, num_speakers):
31
  path, error = convert_to_wav(audio)
 
46
  else:
47
  embeddings = make_embeddings(path, segments, duration)
48
  add_speaker_labels(segments, embeddings, num_speakers)
49
+ global output = get_output(segments)
50
  short_sum=text_to_short_summary(str(output))
51
+ return output
52
 
53
  def convert_to_wav(path):
54
  if path[-3:] != 'wav':
 
105
  #########################################################################
106
 
107
 
108
+ def text_to_short_summary(output):
109
 
110
  from transformers import pipeline
111
  summarizer = pipeline("summarization", model="knkarthick/MEETING-SUMMARY-BART-LARGE-XSUM-SAMSUM-DIALOGSUM")
112
  #text = '''The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.
113
  #'''
114
+ return summarizer(output)
115
 
116
  ###########################################################################
117
 
 
125
 
126
  ],
127
  outputs=[
128
+ (gr.outputs.Textbox(label='Transcript'))
 
129
 
130
  ]
131
  )
132
 
133
+ app2=gr.Interface(
134
+ fn=text_to_short_summary,
135
+ outputs=[gr.outputs.Textbox()]
136
+ )
137
 
138
+ demo=gr.TabbedInterface([app1,app2],["Text","Short_sum"])
139
 
140
+ demo.launch()
141
 
142
 
143