awacke1 commited on
Commit
d14090a
1 Parent(s): b15d938

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -22
app.py CHANGED
@@ -56,21 +56,6 @@ GEN_NAMES = [
56
  "huggingface/EleutherAI/gpt-j-6B",
57
  "huggingface/gpt2-large"
58
  ]
59
- GENERATORS = {}
60
- manager = ModelManager()
61
- for MODEL_NAME in GEN_NAMES :
62
- print(f"downloading {MODEL_NAME}")
63
- model_path, config_path, model_item = manager.download_model(f"{MODEL_NAME}")
64
- #vocoder_name: Optional[str] = model_item["default_vocoder"]
65
- #vocoder_path = None
66
- #vocoder_config_path = None
67
- #if vocoder_name is not None:
68
- # vocoder_path, vocoder_config_path, _ = manager.download_model(vocoder_name)
69
-
70
- #synthesizer = Synthesizer(
71
- # model_path, config_path, None, vocoder_path, vocoder_config_path,
72
- #)
73
- #MODELS[MODEL_NAME] = synthesizer
74
 
75
 
76
  #ASR
@@ -81,6 +66,10 @@ def transcribe(audio):
81
  #Sentiment Classifier
82
  classifier = pipeline("text-classification")
83
 
 
 
 
 
84
  #STT
85
  def speech_to_text(speech):
86
  text = asr(speech)["text"]
@@ -91,6 +80,11 @@ def text_to_sentiment(text):
91
  sentiment = classifier(text)[0]["label"]
92
  return sentiment
93
 
 
 
 
 
 
94
  #Save
95
  def upsert(text):
96
  date_time =str(datetime.datetime.today())
@@ -164,7 +158,7 @@ with demo:
164
  b3.click(upsert, inputs=text, outputs=saved)
165
  b4.click(selectall, inputs=text, outputs=savedAll)
166
  b5.click(tts, inputs=[text,TTSchoice], outputs=audio)
167
- b6.click(ttstory, inputs=[text,Storychoice], outputs=text)
168
 
169
  # Lets Do It
170
  demo.launch(share=True)
@@ -180,9 +174,4 @@ examples = [
180
  ["Collections of people have agency and mass having agency at the mesoscopic level"],
181
  ["Having a deep human connection is an interface problem to solve."],
182
  ["Having a collective creates agency since we build trust in eachother."]
183
- ]
184
-
185
- #gr.Parallel(generator1, generator2, generator3, inputs=gr.inputs.Textbox(lines=5, label="Enter a sentence to get another sentence."),
186
- # title=title, examples=examples).launch(share=False)
187
-
188
-
 
56
  "huggingface/EleutherAI/gpt-j-6B",
57
  "huggingface/gpt2-large"
58
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
 
61
  #ASR
 
66
  #Sentiment Classifier
67
  classifier = pipeline("text-classification")
68
 
69
+ # GPT-J: Story Generation Pipeline
70
+ story_gen = pipeline("text-generation", "pranavpsv/gpt2-genre-story-generator")
71
+
72
+
73
  #STT
74
  def speech_to_text(speech):
75
  text = asr(speech)["text"]
 
80
  sentiment = classifier(text)[0]["label"]
81
  return sentiment
82
 
83
+ #TTStory
84
+ def text_to_story(text):
85
+ story= story_gen(text)[0]["label"]
86
+ return story
87
+
88
  #Save
89
  def upsert(text):
90
  date_time =str(datetime.datetime.today())
 
158
  b3.click(upsert, inputs=text, outputs=saved)
159
  b4.click(selectall, inputs=text, outputs=savedAll)
160
  b5.click(tts, inputs=[text,TTSchoice], outputs=audio)
161
+ b6.click(text_to_story, inputs=[text,Storychoice], outputs=text)
162
 
163
  # Lets Do It
164
  demo.launch(share=True)
 
174
  ["Collections of people have agency and mass having agency at the mesoscopic level"],
175
  ["Having a deep human connection is an interface problem to solve."],
176
  ["Having a collective creates agency since we build trust in eachother."]
177
+ ]