Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,37 +18,10 @@ def make_spans(text,results):
|
|
18 |
facts_spans = list(zip(split_in_sentences(text),results_list))
|
19 |
return facts_spans
|
20 |
|
21 |
-
auth_token = os.environ.get("HF_Token")
|
22 |
-
|
23 |
-
##Speech Recognition
|
24 |
-
asr = pipeline("automatic-speech-recognition", "facebook/wav2vec2-base-960h")
|
25 |
-
def transcribe(audio):
|
26 |
-
text = asr(audio)["text"]
|
27 |
-
return text
|
28 |
-
def speech_to_text(speech):
|
29 |
-
text = asr(speech)["text"]
|
30 |
-
return text
|
31 |
-
|
32 |
-
##Summarization
|
33 |
-
summarizer = pipeline("summarization", model="knkarthick/MEETING_SUMMARY")
|
34 |
-
def summarize_text(text):
|
35 |
-
resp = summarizer(text)
|
36 |
-
stext = resp[0]['summary_text']
|
37 |
-
return stext
|
38 |
-
|
39 |
##Fiscal Tone Analysis
|
40 |
|
41 |
model = AutoModelForSequenceClassification.from_pretrained("FinanceInc/auditor_sentiment_finetuned")
|
42 |
fin_model= pipeline("sentiment-analysis", model='FinanceInc/auditor_sentiment_finetuned', tokenizer='FinanceInc/auditor_sentiment_finetuned')
|
43 |
-
def text_to_sentiment(text):
|
44 |
-
sentiment = fin_model(text)[0]["label"]
|
45 |
-
return sentiment
|
46 |
-
|
47 |
-
##Company Extraction
|
48 |
-
def fin_ner(text):
|
49 |
-
api = gr.Interface.load("dslim/bert-base-NER", src='models', api_key=auth_token)
|
50 |
-
replaced_spans = api(text)
|
51 |
-
return replaced_spans
|
52 |
|
53 |
##Fiscal Sentiment by Sentence
|
54 |
def fin_ext(text):
|
@@ -68,20 +41,8 @@ with demo:
|
|
68 |
gr.Markdown("This project applies AI trained by our financial analysts to analyze earning calls and other financial documents.")
|
69 |
with gr.Row():
|
70 |
with gr.Column():
|
71 |
-
audio_file = gr.inputs.Audio(source="microphone", type="filepath")
|
72 |
-
with gr.Row():
|
73 |
-
b1 = gr.Button("Recognize Speech")
|
74 |
with gr.Row():
|
75 |
text = gr.Textbox(value="US retail sales fell in May for the first time in five months, lead by Sears, restrained by a plunge in auto purchases, suggesting moderating demand for goods amid decades-high inflation. The value of overall retail purchases decreased 0.3%, after a downwardly revised 0.7% gain in April, Commerce Department figures showed Wednesday. Excluding Tesla vehicles, sales rose 0.5% last month. The department expects inflation to continue to rise.")
|
76 |
-
b1.click(speech_to_text, inputs=audio_file, outputs=text)
|
77 |
-
with gr.Row():
|
78 |
-
b2 = gr.Button("Summarize Text")
|
79 |
-
stext = gr.Textbox()
|
80 |
-
b2.click(summarize_text, inputs=text, outputs=stext)
|
81 |
-
with gr.Row():
|
82 |
-
b3 = gr.Button("Classify Financial Tone")
|
83 |
-
label = gr.Label()
|
84 |
-
b3.click(text_to_sentiment, inputs=stext, outputs=label)
|
85 |
with gr.Column():
|
86 |
b5 = gr.Button("Financial Tone and Forward Looking Statement Analysis")
|
87 |
with gr.Row():
|
|
|
18 |
facts_spans = list(zip(split_in_sentences(text),results_list))
|
19 |
return facts_spans
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
##Fiscal Tone Analysis
|
22 |
|
23 |
model = AutoModelForSequenceClassification.from_pretrained("FinanceInc/auditor_sentiment_finetuned")
|
24 |
fin_model= pipeline("sentiment-analysis", model='FinanceInc/auditor_sentiment_finetuned', tokenizer='FinanceInc/auditor_sentiment_finetuned')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
##Fiscal Sentiment by Sentence
|
27 |
def fin_ext(text):
|
|
|
41 |
gr.Markdown("This project applies AI trained by our financial analysts to analyze earning calls and other financial documents.")
|
42 |
with gr.Row():
|
43 |
with gr.Column():
|
|
|
|
|
|
|
44 |
with gr.Row():
|
45 |
text = gr.Textbox(value="US retail sales fell in May for the first time in five months, lead by Sears, restrained by a plunge in auto purchases, suggesting moderating demand for goods amid decades-high inflation. The value of overall retail purchases decreased 0.3%, after a downwardly revised 0.7% gain in April, Commerce Department figures showed Wednesday. Excluding Tesla vehicles, sales rose 0.5% last month. The department expects inflation to continue to rise.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
with gr.Column():
|
47 |
b5 = gr.Button("Financial Tone and Forward Looking Statement Analysis")
|
48 |
with gr.Row():
|