Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
3 |
-
from
|
4 |
-
|
5 |
|
6 |
model_id = "dblasko/blip-dalle3-img2prompt"
|
7 |
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
@@ -21,10 +21,11 @@ def generate_caption(image):
|
|
21 |
|
22 |
return generated_caption, audio_path
|
23 |
|
24 |
-
|
25 |
def play_audio(audio_path):
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
|
29 |
# Create a Gradio interface with an image input, a textbox output, a button, and an audio player
|
30 |
demo = gr.Interface(
|
@@ -37,4 +38,3 @@ demo = gr.Interface(
|
|
37 |
]
|
38 |
)
|
39 |
demo.launch()
|
40 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import BlipProcessor, BlipForConditionalGeneration
|
3 |
+
from gtts import gTTS
|
4 |
+
import pygame
|
5 |
|
6 |
model_id = "dblasko/blip-dalle3-img2prompt"
|
7 |
model = BlipForConditionalGeneration.from_pretrained(model_id)
|
|
|
21 |
|
22 |
return generated_caption, audio_path
|
23 |
|
|
|
24 |
def play_audio(audio_path):
|
25 |
+
pygame.mixer.init()
|
26 |
+
pygame.mixer.music.load(audio_path)
|
27 |
+
pygame.mixer.music.play()
|
28 |
+
pygame.event.wait()
|
29 |
|
30 |
# Create a Gradio interface with an image input, a textbox output, a button, and an audio player
|
31 |
demo = gr.Interface(
|
|
|
38 |
]
|
39 |
)
|
40 |
demo.launch()
|
|