Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
|
|
4 |
|
5 |
pipe = pipeline("image-to-text",
|
6 |
model="Salesforce/blip-image-captioning-base")
|
@@ -9,11 +10,14 @@ tts_pipe = pipeline("text-to-speech",
|
|
9 |
|
10 |
def launch(input):
|
11 |
out = pipe(input)
|
|
|
|
|
|
|
12 |
return out[0]['generated_text']
|
13 |
|
14 |
iface = gr.Interface(launch,
|
15 |
inputs=gr.Image(type='pil'),
|
16 |
outputs="text")
|
17 |
-
iface.
|
18 |
|
19 |
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
+
from IPython.display import Audio as IPythonAudio
|
5 |
|
6 |
pipe = pipeline("image-to-text",
|
7 |
model="Salesforce/blip-image-captioning-base")
|
|
|
10 |
|
11 |
def launch(input):
|
12 |
out = pipe(input)
|
13 |
+
narrated_text = tts_pipe(out[0]['generated_text'])
|
14 |
+
IPythonAudio(narrated_text["audio"][0],
|
15 |
+
rate=narrated_text["sampling_rate"])
|
16 |
return out[0]['generated_text']
|
17 |
|
18 |
iface = gr.Interface(launch,
|
19 |
inputs=gr.Image(type='pil'),
|
20 |
outputs="text")
|
21 |
+
iface.launch()
|
22 |
|
23 |
|