generated from ks6088ts/template-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# References | ||
|
||
- [openai/whisper](https://github.com/openai/whisper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import whisper | ||
|
||
model = whisper.load_model("turbo") | ||
|
||
# load audio and pad/trim it to fit 30 seconds | ||
audio = whisper.load_audio("apps/16_whisper_transcription/sample_audio.wav") | ||
audio = whisper.pad_or_trim(audio) | ||
|
||
# make log-Mel spectrogram and move to the same device as the model | ||
mel = whisper.log_mel_spectrogram(audio).to(model.device) | ||
|
||
# detect the spoken language | ||
_, probs = model.detect_language(mel) | ||
print(f"Detected language: {max(probs, key=probs.get)}") | ||
|
||
# decode the audio | ||
options = whisper.DecodingOptions() | ||
result = whisper.decode(model, mel, options) | ||
|
||
# print the recognized text | ||
print(result.text) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters