Spaces:
Runtime error
Runtime error
import tensorflow as tf | |
import requests | |
from numpy import asarray | |
from transformers import pipeline | |
inception_net = tf.keras.applications.MobileNetV2() | |
# Obteniendo las labels de "https://git.io/JJkYN" | |
response = requests.get("https://git.io/JJkYN") | |
labels = response.text.split("\n") | |
trans = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-large-xlsr-53-spanish") | |
clasificador = pipeline("text-classification", model="pysentimiento/robertuito-sentiment-analysis") | |
def classify_image(inp): | |
inp = asarray(inp.resize((224, 224))) | |
inp = inp.reshape((-1,) + inp.shape) | |
inp = tf.keras.applications.mobilenet_v2.preprocess_input(inp) | |
prediction = inception_net.predict(inp).flatten() | |
confidences = {labels[k]: float(prediction[k]) for k in range(1000)} | |
return confidences | |
def audio2text(audio): | |
text = trans(audio)["text"] | |
return text | |
def text2sentiment(text): | |
return clasificador(text)[0]["label"] |