Update functions.py
Browse files- functions.py +6 -6
functions.py
CHANGED
@@ -30,6 +30,7 @@ margin-bottom: 2.5rem">{}</div> """
|
|
30 |
@st.experimental_singleton(suppress_st_warning=True)
|
31 |
def load_models():
|
32 |
asr_model = whisper.load_model("small")
|
|
|
33 |
q_model = ORTModelForSequenceClassification.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
|
34 |
ner_model = AutoModelForTokenClassification.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
|
35 |
q_tokenizer = AutoTokenizer.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
|
@@ -40,7 +41,7 @@ def load_models():
|
|
40 |
sbert = SentenceTransformer("all-mpnet-base-v2")
|
41 |
cross_encoder = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-12-v2')
|
42 |
|
43 |
-
return
|
44 |
|
45 |
@st.experimental_singleton(suppress_st_warning=True)
|
46 |
def get_spacy():
|
@@ -56,15 +57,14 @@ def inference(link, upload):
|
|
56 |
yt = YouTube(link)
|
57 |
title = yt.title
|
58 |
path = yt.streams.filter(only_audio=True)[0].download(filename="audio.mp4")
|
59 |
-
|
60 |
-
results = asr_model.transcribe(path)
|
61 |
|
62 |
-
return results, yt.title
|
63 |
|
64 |
elif upload:
|
65 |
-
results =
|
66 |
|
67 |
-
return results, "Transcribed Earnings Audio"
|
68 |
|
69 |
@st.experimental_memo(suppress_st_warning=True)
|
70 |
def chunk_long_text(text,threshold):
|
|
|
30 |
@st.experimental_singleton(suppress_st_warning=True)
|
31 |
def load_models():
|
32 |
asr_model = whisper.load_model("small")
|
33 |
+
asr_pipe = pipeline("automatice-speech-recognition",model = "openai/whisper-large")
|
34 |
q_model = ORTModelForSequenceClassification.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
|
35 |
ner_model = AutoModelForTokenClassification.from_pretrained("xlm-roberta-large-finetuned-conll03-english")
|
36 |
q_tokenizer = AutoTokenizer.from_pretrained("nickmuchi/quantized-optimum-finbert-tone")
|
|
|
41 |
sbert = SentenceTransformer("all-mpnet-base-v2")
|
42 |
cross_encoder = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-12-v2')
|
43 |
|
44 |
+
return asr_pipe, sent_pipe, sum_pipe, ner_pipe, sbert, cross_encoder
|
45 |
|
46 |
@st.experimental_singleton(suppress_st_warning=True)
|
47 |
def get_spacy():
|
|
|
57 |
yt = YouTube(link)
|
58 |
title = yt.title
|
59 |
path = yt.streams.filter(only_audio=True)[0].download(filename="audio.mp4")
|
60 |
+
results = asr_pipe(path)
|
|
|
61 |
|
62 |
+
return results['text'], yt.title
|
63 |
|
64 |
elif upload:
|
65 |
+
results = asr_pipe(upload)
|
66 |
|
67 |
+
return results['text'], "Transcribed Earnings Audio"
|
68 |
|
69 |
@st.experimental_memo(suppress_st_warning=True)
|
70 |
def chunk_long_text(text,threshold):
|