Spaces:
Runtime error
Runtime error
File size: 1,800 Bytes
b547275 4471392 a3f583e 4471392 26d1728 b547275 887b3a4 e8046ba 5f9f087 21ea932 923fe92 b3febd2 4017c92 613cde2 4017c92 4471392 4017c92 923fe92 4017c92 e8046ba 4017c92 e8046ba 4017c92 b73c954 4017c92 923fe92 4017c92 |
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
##!/usr/bin/python3
# -*- coding: utf-8 -*-
import os
print("Installing...")
os.system("pip install gradio")
os.system("pip install tf-keras")
os.system("pip install diffusers")
os.system("pip install accelerate")
os.system("pip install transformers")
os.system("pip install numpy")
os.system("pip install torch")
#os.system("pip install --upgrade pip")
print("Installing Finished!")
##!/usr/bin/python3
# -*- coding: utf-8 -*-
from transformers import pipeline
import gradio as gr
import os
import torch
import accelerate
from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler
model_id = "stabilityai/stable-diffusion-2"
scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
image_model = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, torch_dtype=torch.float32)
image_model = image_model.to("cpu")
model = pipeline("automatic-speech-recognition","facebook/wav2vec2-large-xlsr-53-spanish")
def transcribe_text_audio(mic=None, file=None):
if mic is not None:
audio = mic
elif file is not None:
audio = file
else:
return "No se ha detectado ninguna entrada de audio"
transcription = model(audio)["text"]
image = image_model(transcription).images[0]
image = image.convert("RGB")
return transcription, image
gr.Interface(
fn=transcribe_text_audio,
inputs=[
gr.Audio(sources=["microphone"], type="filepath"),
gr.Audio(sources=["upload"], type="filepath"),
],
outputs=[
gr.Textbox(label="Transcripción del Audio"),
gr.Image(label="Imagen Generada")
],
title="[ESpañol] - Audio -> Texto -> Imagen",
description="Esta aplicación transcribe el audio a texto para convertirlo en una imagen descriptiva."
).launch()
|