hushell commited on
Commit
38d8edb
·
1 Parent(s): 8c276e4
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -8,13 +8,14 @@ from requests.models import ChunkedEncodingError
8
  from streamlit.components import v1
9
  from custom import css_code, js_code, set_context_all
10
  from st_audiorec import st_audiorec
 
11
 
12
  device = "cpu"
13
 
14
  # STT
15
  import whisper
16
  WHISPER_LANG = "en" # detecting language if None
17
- warnings.filterwarnings("ignore")
18
  WHISPER_MODEL = whisper.load_model("base")
19
  WHISPER_MODEL.to(device)
20
 
@@ -24,7 +25,7 @@ def transcribe(aud_inp):
24
  if isinstance(aud_inp, str):
25
  aud = whisper.load_audio(aud_inp)
26
  elif isinstance(aud_inp, bytes): # if st_audiorec
27
- aud = np.frombuffer(wav_bytes, dtype=np.uint8).flatten().astype(np.float32) / 255.0
28
  aud = whisper.pad_or_trim(aud)
29
  mel = whisper.log_mel_spectrogram(aud).to(device)
30
  _, probs = WHISPER_MODEL.detect_language(mel)
 
8
  from streamlit.components import v1
9
  from custom import css_code, js_code, set_context_all
10
  from st_audiorec import st_audiorec
11
+ import numpy as np
12
 
13
  device = "cpu"
14
 
15
  # STT
16
  import whisper
17
  WHISPER_LANG = "en" # detecting language if None
18
+ #warnings.filterwarnings("ignore")
19
  WHISPER_MODEL = whisper.load_model("base")
20
  WHISPER_MODEL.to(device)
21
 
 
25
  if isinstance(aud_inp, str):
26
  aud = whisper.load_audio(aud_inp)
27
  elif isinstance(aud_inp, bytes): # if st_audiorec
28
+ aud = np.frombuffer(aud_inp, dtype=np.uint8).flatten().astype(np.float32) / 255.0
29
  aud = whisper.pad_or_trim(aud)
30
  mel = whisper.log_mel_spectrogram(aud).to(device)
31
  _, probs = WHISPER_MODEL.detect_language(mel)