textToSQL commited on
Commit
81033d4
1 Parent(s): dadeb6e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -21
app.py CHANGED
@@ -9,30 +9,30 @@ model = whisper.load_model("small")
9
 
10
 
11
  #option 1
12
- # def transcribe(audio):
13
- # model = whisper.load_model("base")
14
- # result = model.transcribe(audio)
15
- # return result["text"]
16
 
17
  #option 2
18
- def transcribe(audio):
19
 
20
- #time.sleep(3)
21
- # load audio and pad/trim it to fit 30 seconds
22
- audio = whisper.load_audio(audio)
23
- audio = whisper.pad_or_trim(audio)
24
-
25
- # make log-Mel spectrogram and move to the same device as the model
26
- mel = whisper.log_mel_spectrogram(audio).to(model.device)
27
-
28
- # detect the spoken language
29
- _, probs = model.detect_language(mel)
30
- print(f"Detected language: {max(probs, key=probs.get)}")
31
-
32
- # decode the audio
33
- options = whisper.DecodingOptions(fp16 = False)
34
- result = whisper.decode(model, mel, options)
35
- return result.text
36
 
37
 
38
  def process_text(input_text):
 
9
 
10
 
11
  #option 1
12
+ def transcribe(audio):
13
+ model = whisper.load_model("base")
14
+ result = model.transcribe(audio)
15
+ return result["text"]
16
 
17
  #option 2
18
+ # def transcribe(audio):
19
 
20
+ # #time.sleep(3)
21
+ # # load audio and pad/trim it to fit 30 seconds
22
+ # audio = whisper.load_audio(audio)
23
+ # audio = whisper.pad_or_trim(audio)
24
+
25
+ # # make log-Mel spectrogram and move to the same device as the model
26
+ # mel = whisper.log_mel_spectrogram(audio).to(model.device)
27
+
28
+ # # detect the spoken language
29
+ # _, probs = model.detect_language(mel)
30
+ # print(f"Detected language: {max(probs, key=probs.get)}")
31
+
32
+ # # decode the audio
33
+ # options = whisper.DecodingOptions(fp16 = False)
34
+ # result = whisper.decode(model, mel, options)
35
+ # return result.text
36
 
37
 
38
  def process_text(input_text):