iqbalc commited on
Commit
8f2a47a
·
1 Parent(s): b0ae371

Create new file

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import whisper
2
+ model = whisper.load_model("large")
3
+ import gradio as gr
4
+ import time
5
+ def transcribe(audio):
6
+
7
+ #time.sleep(3)
8
+ # load audio and pad/trim it to fit 30 seconds
9
+ audio = whisper.load_audio(audio)
10
+ audio = whisper.pad_or_trim(audio)
11
+
12
+ # make log-Mel spectrogram and move to the same device as the model
13
+ mel = whisper.log_mel_spectrogram(audio).to(model.device)
14
+
15
+ # detect the spoken language
16
+ _, probs = model.detect_language(mel)
17
+ print(f"Detected language: {max(probs, key=probs.get)}")
18
+
19
+ # decode the audio
20
+ options = whisper.DecodingOptions()
21
+ result = whisper.decode(model, mel, options)
22
+ return result.text