File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
apps/16_whisper_transcription Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 1
1
# References
2
2
3
3
- [ openai/whisper] ( https://github.com/openai/whisper )
4
+ - [ Improve --model argument handling and help message #1764 ] ( https://github.com/openai/whisper/pull/1764 )
Original file line number Diff line number Diff line change 1
1
import whisper
2
2
3
- model = whisper .load_model ("turbo" )
3
+ # https://github.com/openai/whisper?tab=readme-ov-file#python-usage
4
+ model_name = "turbo"
5
+ file_path = "dist/sample_audio.wav"
6
+
7
+ model = whisper .load_model (name = model_name )
4
8
5
9
# load audio and pad/trim it to fit 30 seconds
6
- audio = whisper .load_audio ("apps/16_whisper_transcription/sample_audio.wav" )
7
- audio = whisper .pad_or_trim (audio )
10
+ audio = whisper .load_audio (
11
+ file = file_path ,
12
+ )
13
+ audio = whisper .pad_or_trim (
14
+ array = audio ,
15
+ length = 30 * 16000 ,
16
+ )
8
17
9
18
# make log-Mel spectrogram and move to the same device as the model
10
- mel = whisper .log_mel_spectrogram (audio ).to (model .device )
19
+ # https://github.com/openai/whisper/pull/1764
20
+ mel = whisper .log_mel_spectrogram (
21
+ audio = audio ,
22
+ n_mels = 128 ,
23
+ ).to (model .device )
11
24
12
25
# detect the spoken language
13
26
_ , probs = model .detect_language (mel )
You can’t perform that action at this time.
0 commit comments