drmurataltun's picture
Create app.py
58662fc verified
raw
history blame
684 Bytes
from transformers import pipeline
import gradio as gr
asr = pipeline("automatic-speech-recognition", model="facebook/wav2vec2-base-960h")
classifier = pipeline("text-classification")
def speech_to_text(speech):
text = asr(speech)["text"]
return text
def text_to_sentiment(text):
return classifier(text)[0]["label"]
demo = gr.Blocks()
with demo:
audio_file = gr.Audio(type="filepath")
text = gr.Textbox()
label = gr.Label()
b1 = gr.Button("Konuşmayı Tanı")
b2 = gr.Button("Duygu Sınıflandırıcı")
b1.click(speech_to_text, inputs=audio_file, outputs=text)
b2.click(text_to_sentiment, inputs=text, outputs=label)
demo.launch()