Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
transcription = pipeline("automatic-speech-recognition", model = "facebook/wav2vec2-large-xlsr-53-spanish")
|
| 5 |
+
clasification = pipeline("text-classification", model = "pysentimiento/robertuito-sentiment-analysis")
|
| 6 |
+
|
| 7 |
+
def audio_a_text(audio):
|
| 8 |
+
text = transcription(audio)["text"]
|
| 9 |
+
return text
|
| 10 |
+
|
| 11 |
+
def text_to_sentimient(audio):
|
| 12 |
+
text = transcription(audio)["text"]
|
| 13 |
+
return clasification(text)[0]["label"]
|
| 14 |
+
|
| 15 |
+
demo = gr.Blocks()
|
| 16 |
+
|
| 17 |
+
with demo:
|
| 18 |
+
gr.Markdown("Speech analyzer")
|
| 19 |
+
audio = gr.Audio(type="filepath", label = "Upload a file")
|
| 20 |
+
text = gr.Textbox()
|
| 21 |
+
b1 = gr.Button("convert to text")
|
| 22 |
+
b1.click(audio_a_text, inputs=audio, outputs=text)
|
| 23 |
+
|
| 24 |
+
b2 = gr.Button("Classification of speech")
|
| 25 |
+
b2.click(text_to_sentimient, inputs=audio, outputs=text)
|
| 26 |
+
|
| 27 |
+
demo.launch()
|