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 11# References
22
33- [ 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 11import whisper
22
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 )
48
59# 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+ )
817
918# 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 )
1124
1225# detect the spoken language
1326_ , probs = model .detect_language (mel )
You can’t perform that action at this time.
0 commit comments