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