Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,6 @@
|
|
1 |
-
|
2 |
-
|
3 |
# Import libraries
|
4 |
import gradio as gr
|
5 |
from transformers import pipeline
|
6 |
-
from gtts import gTTS
|
7 |
-
from io import BytesIO
|
8 |
-
from IPython.display import Audio
|
9 |
|
10 |
# Create a text generation pipeline with GPT-2
|
11 |
story_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B")
|
@@ -22,22 +17,16 @@ def StorytellerGPT(tell_story):
|
|
22 |
|
23 |
messages.append({"role": "assistant", "content": story_reply})
|
24 |
|
25 |
-
|
26 |
-
tts = gTTS(text=story_reply, lang='en', slow=False)
|
27 |
-
audio_io = BytesIO()
|
28 |
-
tts.save(audio_io)
|
29 |
-
audio_io.seek(0)
|
30 |
-
|
31 |
-
return story_reply, Audio(data=audio_io.read(), autoplay=True)
|
32 |
|
33 |
# Create the Gradio Interface
|
34 |
demo = gr.Interface(
|
35 |
fn=StorytellerGPT,
|
36 |
inputs="text",
|
37 |
-
outputs=
|
38 |
title="π Storytelling Magic",
|
39 |
description="A magical storyteller app for kids! Type a sentence, and let the app create an enchanting story for you."
|
40 |
)
|
41 |
|
42 |
# Launch the Gradio Interface
|
43 |
-
demo.launch()
|
|
|
|
|
|
|
1 |
# Import libraries
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
|
|
|
|
|
|
4 |
|
5 |
# Create a text generation pipeline with GPT-2
|
6 |
story_generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B")
|
|
|
17 |
|
18 |
messages.append({"role": "assistant", "content": story_reply})
|
19 |
|
20 |
+
return story_reply
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Create the Gradio Interface
|
23 |
demo = gr.Interface(
|
24 |
fn=StorytellerGPT,
|
25 |
inputs="text",
|
26 |
+
outputs="text",
|
27 |
title="π Storytelling Magic",
|
28 |
description="A magical storyteller app for kids! Type a sentence, and let the app create an enchanting story for you."
|
29 |
)
|
30 |
|
31 |
# Launch the Gradio Interface
|
32 |
+
demo.launch()
|