File size: 1,828 Bytes
7a7ebdf ff39d68 4240a50 ff39d68 d250ad6 d02f0ba 35b1732 ff39d68 d250ad6 ff39d68 d02f0ba ff39d68 0e1f235 ff39d68 35b1732 ff39d68 35b1732 ff39d68 a212991 d250ad6 564ec1c d250ad6 35b1732 d250ad6 ff39d68 0e1f235 ff39d68 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
import gradio as gr
import os
asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
auth_token = os.environ.get("HF_Token")
tokenizer = AutoTokenizer.from_pretrained("demo-org/auditor_review_model",use_auth_token=auth_token)
audit_model = AutoModelForSequenceClassification.from_pretrained("demo-org/auditor_review_model",use_auth_token=auth_token)
nlp = pipeline("text-classification", model=audit_model, tokenizer=tokenizer)
def transcribe(audio):
text = asr(audio)["text"]
return text
def speech_to_text(speech):
text = asr(speech)["text"]
return text
def summarize_text(text):
stext = summarizer(text)
return stext
def text_to_sentiment(text):
sentiment = nlp(text)[0]["label"]
return sentiment
def ner(text):
api = gr.Interface.load("wolfrage89/company_segment_ner", src='models')
spans = api(text)
replaced_spans = [(key, None) if value=='No Disease' else (key, value) for (key, value) in spans]
return replaced_spans
demo = gr.Blocks()
with demo:
audio_file = gr.inputs.Audio(source="microphone", type="filepath")
b1 = gr.Button("Recognize Speech")
text = gr.Textbox()
b1.click(speech_to_text, inputs=audio_file, outputs=text)
b2 = gr.Button("Summarize Text")
stext = gr.Textbox()
b2.click(summarize_text, inputs=text, outputs=stext)
b3 = gr.Button("Classify Sentiment")
label = gr.Label()
b3.click(text_to_sentiment, inputs=stext, outputs=label)
b4 = gr.Button("Extract Companies & Segments")
label = gr.Label()
b4.click(text_to_sentiment, inputs=stext, outputs=label)
demo.launch(share=True) |