nickmuchi commited on
Commit
27f73e5
1 Parent(s): 455a7e5

Update functions.py

Browse files
Files changed (1) hide show
  1. functions.py +1 -18
functions.py CHANGED
@@ -76,29 +76,12 @@ def inference(link, upload, _asr_model):
76
  results = _asr_model.trasncribe(upload)
77
 
78
  return results['text'], "Transcribed Earnings Audio"
79
-
80
- @st.experimental_memo(suppress_st_warning=True)
81
- def chunk_long_text(text,threshold):
82
- '''Chunk long text'''
83
- sentences = sent_tokenize(text)
84
- out = []
85
-
86
- for chunk in sentences:
87
- if len(chunk.split()) < threshold:
88
- out.append(chunk)
89
- else:
90
- words = chunk.split()
91
- num = int(len(words)/threshold)
92
- for i in range(0,num*threshold+1,threshold):
93
- out.append(' '.join(words[i:threshold+i]))
94
-
95
- return out
96
 
97
  @st.experimental_memo(suppress_st_warning=True)
98
  def sentiment_pipe(earnings_text):
99
  '''Determine the sentiment of the text'''
100
 
101
- earnings_sentences = chunk_long_text(earnings_text,400)
102
  earnings_sentiment = sent_pipe(earnings_sentences)
103
 
104
  return earnings_sentiment, earnings_sentences
 
76
  results = _asr_model.trasncribe(upload)
77
 
78
  return results['text'], "Transcribed Earnings Audio"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  @st.experimental_memo(suppress_st_warning=True)
81
  def sentiment_pipe(earnings_text):
82
  '''Determine the sentiment of the text'''
83
 
84
+ earnings_sentences = chunk_long_text(earnings_text,200,1)
85
  earnings_sentiment = sent_pipe(earnings_sentences)
86
 
87
  return earnings_sentiment, earnings_sentences