imseldrith commited on
Commit
4a0aeac
·
1 Parent(s): 9c6f929

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -6,7 +6,7 @@ import os
6
  import difflib
7
 
8
  # Create a Parrot instance
9
- parrot = Parrot(model_tag="turing", use_gpu=False)
10
 
11
  # Supported languages for paraphrasing
12
  languages = {
@@ -18,8 +18,9 @@ languages = {
18
 
19
  # Supported models for paraphrasing
20
  models = {
21
- "Turing": "turing",
22
- "Pegasus": "pegasus"
 
23
  }
24
 
25
  def paraphrase_text(text, language, model, level):
@@ -52,21 +53,21 @@ interface = gr.Interface(
52
  gr.inputs.Slider(minimum=1, maximum=10, default=5, label="Level of paraphrasing:"),
53
  gr.inputs.Checkbox(label="Generate audio output?"),
54
  gr.inputs.File(label="Upload file containing text to paraphrase (Optional):")
55
- ],
56
- outputs=[
57
- gr.outputs.Textbox(label="Paraphrased text:"),
58
- gr.outputs.Download(label="Download paraphrased text as text file:"),
59
- gr.outputs.HTML(label="Highlighted differences:")
60
- ],
61
- title="Parrot Paraphrasing Tool",
62
- description="Enter text to paraphrase, select language and model, and choose level of paraphrasing."
63
  )
64
 
65
  def app(text, language, model, level, audio_output, file_upload):
66
  if file_upload:
67
  with open(file_upload.name, "r", encoding="utf-8") as f:
68
  text = f.read()
69
- paraphrased_text = paraphrase_text(text, languages[language], models[model], level)
70
  if audio_output:
71
  speak_paraphrased_text(paraphrased_text, languages[language])
72
  download_output = gr.outputs.Download(paraphrased_text, label="Download paraphrased text as text file:", mime_type="text/plain")
 
6
  import difflib
7
 
8
  # Create a Parrot instance
9
+ parrot = Parrot(model_tag="t5-small", use_gpu=False)
10
 
11
  # Supported languages for paraphrasing
12
  languages = {
 
18
 
19
  # Supported models for paraphrasing
20
  models = {
21
+ "T5 Small": "t5-small",
22
+ "T5 Base": "t5-base",
23
+ "Pegasus": "google/pegasus-multi_news"
24
  }
25
 
26
  def paraphrase_text(text, language, model, level):
 
53
  gr.inputs.Slider(minimum=1, maximum=10, default=5, label="Level of paraphrasing:"),
54
  gr.inputs.Checkbox(label="Generate audio output?"),
55
  gr.inputs.File(label="Upload file containing text to paraphrase (Optional):")
56
+ ],
57
+ outputs=[
58
+ gr.outputs.Textbox(label="Paraphrased text:"),
59
+ gr.outputs.Download(label="Download paraphrased text as text file:"),
60
+ gr.outputs.HTML(label="Highlighted differences:")
61
+ ],
62
+ title="Parrot Paraphrasing Tool",
63
+ description="Enter text to paraphrase, select language and model, and choose level of paraphrasing."
64
  )
65
 
66
  def app(text, language, model, level, audio_output, file_upload):
67
  if file_upload:
68
  with open(file_upload.name, "r", encoding="utf-8") as f:
69
  text = f.read()
70
+ paraphrased_text = paraphrase_text(text, languages[language], models[model], level)
71
  if audio_output:
72
  speak_paraphrased_text(paraphrased_text, languages[language])
73
  download_output = gr.outputs.Download(paraphrased_text, label="Download paraphrased text as text file:", mime_type="text/plain")