Update app.py
Browse files
app.py
CHANGED
|
@@ -32,18 +32,20 @@ def audio_to_text(audio_path):
|
|
| 32 |
return result["text"]
|
| 33 |
|
| 34 |
# ------------------------------
|
| 35 |
-
# 3.
|
| 36 |
# ------------------------------
|
| 37 |
|
| 38 |
-
def pipeline(
|
| 39 |
-
if not
|
| 40 |
return []
|
| 41 |
|
| 42 |
resultados = []
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
sentimento = predict_sentiment(texto)
|
| 46 |
-
resultados.append([
|
| 47 |
|
| 48 |
return resultados
|
| 49 |
|
|
@@ -53,17 +55,16 @@ def pipeline(lista_audios):
|
|
| 53 |
|
| 54 |
app = gr.Interface(
|
| 55 |
fn=pipeline,
|
| 56 |
-
inputs=gr.
|
| 57 |
-
|
| 58 |
-
label="Envie seus
|
| 59 |
-
multiple=True
|
| 60 |
),
|
| 61 |
outputs=gr.Dataframe(
|
| 62 |
headers=["Arquivo", "Texto reconhecido", "Sentimento"],
|
| 63 |
label="Resultados"
|
| 64 |
),
|
| 65 |
title="Análise de Sentimento por Áudio",
|
| 66 |
-
description="Envie
|
| 67 |
)
|
| 68 |
|
| 69 |
app.launch()
|
|
|
|
| 32 |
return result["text"]
|
| 33 |
|
| 34 |
# ------------------------------
|
| 35 |
+
# 3. Pipeline para vários arquivos
|
| 36 |
# ------------------------------
|
| 37 |
|
| 38 |
+
def pipeline(lista_arquivos):
|
| 39 |
+
if not lista_arquivos:
|
| 40 |
return []
|
| 41 |
|
| 42 |
resultados = []
|
| 43 |
+
|
| 44 |
+
for arquivo in lista_arquivos:
|
| 45 |
+
caminho = arquivo.name # gr.File fornece um objeto, usamos .name
|
| 46 |
+
texto = audio_to_text(caminho)
|
| 47 |
sentimento = predict_sentiment(texto)
|
| 48 |
+
resultados.append([arquivo.name, texto, sentimento])
|
| 49 |
|
| 50 |
return resultados
|
| 51 |
|
|
|
|
| 55 |
|
| 56 |
app = gr.Interface(
|
| 57 |
fn=pipeline,
|
| 58 |
+
inputs=gr.File(
|
| 59 |
+
file_count="multiple",
|
| 60 |
+
label="Envie seus arquivos de áudio (WAV, MP3, OGG...)"
|
|
|
|
| 61 |
),
|
| 62 |
outputs=gr.Dataframe(
|
| 63 |
headers=["Arquivo", "Texto reconhecido", "Sentimento"],
|
| 64 |
label="Resultados"
|
| 65 |
),
|
| 66 |
title="Análise de Sentimento por Áudio",
|
| 67 |
+
description="Envie múltiplos áudios. O sistema usa Whisper para transcrição e um modelo treinado para detectar sentimento."
|
| 68 |
)
|
| 69 |
|
| 70 |
app.launch()
|