Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,19 +7,19 @@ import time
|
|
| 7 |
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
-
# Generates a caption for the given image using a pre-trained model
|
| 11 |
def image_to_caption(image_path):
|
| 12 |
imgtocaption = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
|
| 13 |
caption = imgtocaption(image_path)[0]['generated_text']
|
| 14 |
return caption
|
| 15 |
|
| 16 |
-
# Generates a story for the caption using a pre-trained model
|
| 17 |
def caption_to_story(text):
|
| 18 |
captiontostory = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")
|
| 19 |
story = captiontostory(text,max_length=150,min_length=50)[0]['generated_text']
|
| 20 |
return story
|
| 21 |
|
| 22 |
-
# Generates an audio for the story
|
| 23 |
def story_to_audio(text):
|
| 24 |
audio = io.BytesIO()
|
| 25 |
tts = gTTS(text=text, lang='en', slow=False)
|
|
|
|
| 7 |
|
| 8 |
from transformers import pipeline
|
| 9 |
|
| 10 |
+
# Generates a caption for the given image using a pre-trained model
|
| 11 |
def image_to_caption(image_path):
|
| 12 |
imgtocaption = pipeline("image-to-text", model="Salesforce/blip-image-captioning-base")
|
| 13 |
caption = imgtocaption(image_path)[0]['generated_text']
|
| 14 |
return caption
|
| 15 |
|
| 16 |
+
# Generates a story for the caption using a pre-trained model
|
| 17 |
def caption_to_story(text):
|
| 18 |
captiontostory = pipeline("text-generation", model="pranavpsv/genre-story-generator-v2")
|
| 19 |
story = captiontostory(text,max_length=150,min_length=50)[0]['generated_text']
|
| 20 |
return story
|
| 21 |
|
| 22 |
+
# Generates an audio for the story
|
| 23 |
def story_to_audio(text):
|
| 24 |
audio = io.BytesIO()
|
| 25 |
tts = gTTS(text=text, lang='en', slow=False)
|