JoelJebaraj93 commited on
Commit
71eb037
·
verified ·
1 Parent(s): c61c854

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -10,8 +10,7 @@ translator_de = pipeline("translation", model="Helsinki-NLP/opus-mt-en-de")
10
  translator_es = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
11
  translator_ta = pipeline("translation", model="facebook/nllb-200-distilled-600M", src_lang="eng_Latn", tgt_lang="tam_Taml")
12
  speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-small")
13
- question_generator = pipeline("e2e-qg")
14
-
15
  # Functional logic
16
  def summarize(text):
17
  return summarizer(text, max_length=60, min_length=20, do_sample=False)[0]['summary_text']
@@ -44,8 +43,10 @@ def transcribe(audio):
44
  return speech_to_text(audio)["text"]
45
 
46
  def generate_questions(text):
47
- output = question_generator(text)
48
- return "\n".join(f"- {item['question']}" for item in output[:10])
 
 
49
 
50
  # UI App
51
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
10
  translator_es = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
11
  translator_ta = pipeline("translation", model="facebook/nllb-200-distilled-600M", src_lang="eng_Latn", tgt_lang="tam_Taml")
12
  speech_to_text = pipeline("automatic-speech-recognition", model="openai/whisper-small")
13
+ question_generator = pipeline("text2text-generation", model="valhalla/t5-base-e2e-qg")
 
14
  # Functional logic
15
  def summarize(text):
16
  return summarizer(text, max_length=60, min_length=20, do_sample=False)[0]['summary_text']
 
43
  return speech_to_text(audio)["text"]
44
 
45
  def generate_questions(text):
46
+ prompt = "generate questions: " + text
47
+ result = question_generator(prompt, max_length=256, do_sample=False)
48
+ return result[0]["generated_text"]
49
+
50
 
51
  # UI App
52
  with gr.Blocks(theme=gr.themes.Soft()) as demo: