Skip to content

Instantly share code, notes, and snippets.

@jeanmidevacc
Last active January 28, 2024 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanmidevacc/8c608fa7a96b31c140adb3f9c45ee72b to your computer and use it in GitHub Desktop.
Save jeanmidevacc/8c608fa7a96b31c140adb3f9c45ee72b to your computer and use it in GitHub Desktop.
local_whisper.py
import whisper
size_model = "medium" #the type of model in the model card , with .en or not
model = whisper.load_model(size_model, device="cuda")
def get_transcript_local_whisper(model, file, language):
audio = whisper.load_audio(file)
audio = whisper.pad_or_trim(audio)
mel = whisper.log_mel_spectrogram(audio).to(model.device)
result = whisper.decode(model, mel, language=language)
return result.text
transcript = get_transcript_local_whisper(model, file, "fr")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment