Skip to content

Commit e8bd175

Browse files
committed
wip
1 parent ea681ca commit e8bd175

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
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)

apps/16_whisper_transcription/main.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import 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)

0 commit comments

Comments
 (0)