kodamkarthik281 commited on
Commit
b782833
·
verified ·
1 Parent(s): 5c89f16

Update streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +0 -4
streamlit_app.py CHANGED
@@ -10,7 +10,6 @@ from scipy.io.wavfile import write
10
  st.title("Real-Time Speech-to-Text Transcriber")
11
  st.markdown("Upload an audio file to get the transcription with timestamps.")
12
 
13
- # ⏳ Cache model to reduce loading time
14
  @st.cache_resource
15
  def load_model():
16
  return whisper.load_model("small")
@@ -20,10 +19,8 @@ model = load_model()
20
  def transcribe_audio(file):
21
  audio, sr = librosa.load(file, sr=None)
22
 
23
- # Noise reduction
24
  audio = nr.reduce_noise(y=audio, sr=sr)
25
 
26
- # Trim to 30s for performance
27
  max_duration = 30
28
  audio = audio[:sr * max_duration]
29
 
@@ -31,7 +28,6 @@ def transcribe_audio(file):
31
  audio = librosa.resample(audio, orig_sr=sr, target_sr=16000)
32
  sr = 16000
33
 
34
- # Save to temp WAV
35
  with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp:
36
  write(tmp.name, sr, (audio * 32767).astype(np.int16))
37
  result = model.transcribe(tmp.name, fp16=False)
 
10
  st.title("Real-Time Speech-to-Text Transcriber")
11
  st.markdown("Upload an audio file to get the transcription with timestamps.")
12
 
 
13
  @st.cache_resource
14
  def load_model():
15
  return whisper.load_model("small")
 
19
  def transcribe_audio(file):
20
  audio, sr = librosa.load(file, sr=None)
21
 
 
22
  audio = nr.reduce_noise(y=audio, sr=sr)
23
 
 
24
  max_duration = 30
25
  audio = audio[:sr * max_duration]
26
 
 
28
  audio = librosa.resample(audio, orig_sr=sr, target_sr=16000)
29
  sr = 16000
30
 
 
31
  with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp:
32
  write(tmp.name, sr, (audio * 32767).astype(np.int16))
33
  result = model.transcribe(tmp.name, fp16=False)