patharanor commited on
Commit
7fc5b77
·
1 Parent(s): 7128a95

feat:added chunk length

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -1,9 +1,17 @@
1
  import gradio as gr
 
2
  from transformers import pipeline
3
  import numpy as np
4
 
5
- model_name = "biodatlab/whisper-th-medium-combined"
6
- transcriber = pipeline("automatic-speech-recognition", model=model_name)
 
 
 
 
 
 
 
7
 
8
  def transcribe(audio):
9
  sr, y = audio
 
1
  import gradio as gr
2
+ import torch
3
  from transformers import pipeline
4
  import numpy as np
5
 
6
+ MODEL_NAME = "biodatlab/whisper-th-medium-combined"
7
+ DEVICE = 0 if torch.cuda.is_available() else "cpu"
8
+
9
+ transcriber = pipeline(
10
+ "automatic-speech-recognition",
11
+ model=MODEL_NAME,
12
+ chunk_length_s=30,
13
+ device=DEVICE
14
+ )
15
 
16
  def transcribe(audio):
17
  sr, y = audio