Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,14 +2,13 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
import huggingsound
|
| 4 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
| 5 |
-
|
| 6 |
|
| 7 |
def modelo1(audio):
|
| 8 |
model = SpeechRecognitionModel("jonatasgrosman/wav2vec2-large-xlsr-53-english")
|
| 9 |
transcriptions = model.transcribe(audio)
|
| 10 |
return transcriptions
|
| 11 |
|
| 12 |
-
|
| 13 |
def modelo2(text):
|
| 14 |
model_id = "stabilityai/stable-diffusion-2-1"
|
| 15 |
|
|
@@ -19,12 +18,13 @@ def modelo2(text):
|
|
| 19 |
pipe = pipe.to("cuda")
|
| 20 |
|
| 21 |
image = pipe(text).images[0]
|
| 22 |
-
|
| 23 |
|
| 24 |
def execution(audio):
|
| 25 |
modelo1res = modelo1(audio)
|
| 26 |
modelo2res = modelo2(modelo1res)
|
| 27 |
-
return
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
|
|
|
| 30 |
demo.launch()
|
|
|
|
| 2 |
import torch
|
| 3 |
import huggingsound
|
| 4 |
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
|
| 5 |
+
from transformers import SpeechRecognitionModel
|
| 6 |
|
| 7 |
def modelo1(audio):
|
| 8 |
model = SpeechRecognitionModel("jonatasgrosman/wav2vec2-large-xlsr-53-english")
|
| 9 |
transcriptions = model.transcribe(audio)
|
| 10 |
return transcriptions
|
| 11 |
|
|
|
|
| 12 |
def modelo2(text):
|
| 13 |
model_id = "stabilityai/stable-diffusion-2-1"
|
| 14 |
|
|
|
|
| 18 |
pipe = pipe.to("cuda")
|
| 19 |
|
| 20 |
image = pipe(text).images[0]
|
| 21 |
+
return image
|
| 22 |
|
| 23 |
def execution(audio):
|
| 24 |
modelo1res = modelo1(audio)
|
| 25 |
modelo2res = modelo2(modelo1res)
|
| 26 |
+
return modelo2res
|
| 27 |
|
| 28 |
if __name__ == "__main__":
|
| 29 |
+
demo = gr.Interface(fn=execution, inputs="audio", outputs="image")
|
| 30 |
demo.launch()
|