Emmanuel08 commited on
Commit
ed02176
·
verified ·
1 Parent(s): 3c16c41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -4,19 +4,19 @@ import gradio as gr
4
  import time
5
  import numpy as np
6
  import scipy.io.wavfile
 
7
 
8
  # ✅ 1️⃣ Load Silero STT Model for CPU
9
- device = torch.device("cpu") # ✅ Ensuring CPU-only execution
10
  torch_dtype = torch.float32
11
 
12
- MODEL_NAME = "silero_stt"
13
-
14
- # ✅ 2️⃣ Load Silero Model & Decoder
15
- torch.set_num_threads(4) # ✅ Improve CPU performance by using multiple threads
16
  model, decoder, utils = torch.hub.load(repo_or_dir="snakers4/silero-models",
17
  model="silero_stt",
18
  language="en",
19
- device=device)
 
20
  (read_batch, split_into_batches, read_audio, prepare_model_input) = utils
21
 
22
  # ✅ 3️⃣ Real-Time Streaming Transcription (Microphone)
@@ -132,4 +132,4 @@ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
132
 
133
  # ✅ 9️⃣ Run Gradio Locally
134
  if __name__ == "__main__":
135
- demo.launch()
 
4
  import time
5
  import numpy as np
6
  import scipy.io.wavfile
7
+ from omegaconf import OmegaConf # ✅ Fix: Import omegaconf
8
 
9
  # ✅ 1️⃣ Load Silero STT Model for CPU
10
+ device = torch.device("cpu")
11
  torch_dtype = torch.float32
12
 
13
+ # ✅ 2️⃣ Load Silero Model & Decoder with `trust_repo=True`
14
+ torch.set_num_threads(4)
 
 
15
  model, decoder, utils = torch.hub.load(repo_or_dir="snakers4/silero-models",
16
  model="silero_stt",
17
  language="en",
18
+ device=device,
19
+ trust_repo=True) # ✅ Fix: Avoids untrusted repo warning
20
  (read_batch, split_into_batches, read_audio, prepare_model_input) = utils
21
 
22
  # ✅ 3️⃣ Real-Time Streaming Transcription (Microphone)
 
132
 
133
  # ✅ 9️⃣ Run Gradio Locally
134
  if __name__ == "__main__":
135
+ demo.launch()