storresbusquets commited on
Commit
5b575aa
·
1 Parent(s): 9e1df22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -44,7 +44,7 @@ class GradioInference:
44
 
45
 
46
 
47
- def __call__(self, link, lang, size):
48
  """
49
  Call the Gradio Inference python class.
50
  This class gets access to a YouTube video using python's library Pytube and downloads its audio.
@@ -55,6 +55,7 @@ class GradioInference:
55
  - Sentiment Analysis: using Hugging Face's default sentiment classifier
56
  - WordCloud: using the wordcloud python library.
57
  """
 
58
  if self.yt is None:
59
  self.yt = YouTube(link)
60
 
@@ -68,9 +69,11 @@ class GradioInference:
68
  self.loaded_model = whisper.load_model(size)
69
  self.current_size = size
70
 
 
71
  # Transcribe the audio extracted from pytube
72
  results = self.loaded_model.transcribe(path, language=lang)
73
 
 
74
  # Perform summarization on the transcription
75
  transcription_summary = self.summarizer(
76
  results["text"], max_length=150, min_length=30, do_sample=False
@@ -101,7 +104,7 @@ class GradioInference:
101
  )
102
  #### Fin prueba
103
 
104
-
105
  # Extract keywords using VoiceLabT5
106
  task_prefix = "Keywords: "
107
  input_sequence = task_prefix + results["text"]
@@ -114,9 +117,11 @@ class GradioInference:
114
  predicted = self.keyword_tokenizer.decode(output[0], skip_special_tokens=True)
115
  keywords = [x.strip() for x in predicted.split(",") if x.strip()]
116
 
 
117
  # Sentiment label
118
  label = self.classifier(summary)[0]["label"]
119
-
 
120
  # Generate WordCloud object
121
  wordcloud = WordCloud(colormap = "Oranges").generate(results["text"])
122
 
 
44
 
45
 
46
 
47
+ def __call__(self, link, lang, size, progress=gr.Progress()):
48
  """
49
  Call the Gradio Inference python class.
50
  This class gets access to a YouTube video using python's library Pytube and downloads its audio.
 
55
  - Sentiment Analysis: using Hugging Face's default sentiment classifier
56
  - WordCloud: using the wordcloud python library.
57
  """
58
+ progress(0, desc="Starting analysis")
59
  if self.yt is None:
60
  self.yt = YouTube(link)
61
 
 
69
  self.loaded_model = whisper.load_model(size)
70
  self.current_size = size
71
 
72
+ progress(0.20, desc="Transcribing")
73
  # Transcribe the audio extracted from pytube
74
  results = self.loaded_model.transcribe(path, language=lang)
75
 
76
+ progress(0.35, desc="Summarizing")
77
  # Perform summarization on the transcription
78
  transcription_summary = self.summarizer(
79
  results["text"], max_length=150, min_length=30, do_sample=False
 
104
  )
105
  #### Fin prueba
106
 
107
+ progress(0.50, desc="Extracting Keywords")
108
  # Extract keywords using VoiceLabT5
109
  task_prefix = "Keywords: "
110
  input_sequence = task_prefix + results["text"]
 
117
  predicted = self.keyword_tokenizer.decode(output[0], skip_special_tokens=True)
118
  keywords = [x.strip() for x in predicted.split(",") if x.strip()]
119
 
120
+ progress(0.75, desc="Extracting Sentiment")
121
  # Sentiment label
122
  label = self.classifier(summary)[0]["label"]
123
+
124
+ progress(0.90, desc="Generating Wordcloud")
125
  # Generate WordCloud object
126
  wordcloud = WordCloud(colormap = "Oranges").generate(results["text"])
127