textToSQL commited on
Commit
54ecabd
·
1 Parent(s): 6f19d22

Update app.py

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