Spaces:
Sleeping
Sleeping
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() |