File size: 698 Bytes
000c2c2
 
 
cca9a4c
000c2c2
 
18d8458
1c09801
000c2c2
 
 
 
 
1c09801
000c2c2
18d8458
000c2c2
 
 
 
 
18d8458
000c2c2
18d8458
 
12a6969
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import gradio as gr
from transformers import pipeline
from TTS.api import TTS

captioner = pipeline(model="microsoft/git-base")
tts = TTS(model_name="tts_models/multilingual/multi-dataset/your_tts", progress_bar=False, gpu=False)


def predict(image):
    text = captioner(image)[0]["generated_text"]

    audio_output = "output.wav"
    tts.tts_to_file(text, speaker=tts.speakers[0], language="en", file_path=audio_output)
    
    return text, audio_output

demo = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs=['text', gr.Audio()]
)

demo.launch()

# gr.Interface.load("models/ronniet/git-base-env").launch()
# gr.Interface.load("models/microsoft/git-base").launch()