Skip to content

Instantly share code, notes, and snippets.

@rajtilakjee
Created June 26, 2023 05:00
Show Gist options
  • Save rajtilakjee/a4c4fdff2285c3c855fadfc2cbb87de3 to your computer and use it in GitHub Desktop.
Save rajtilakjee/a4c4fdff2285c3c855fadfc2cbb87de3 to your computer and use it in GitHub Desktop.
YouTube Transcriber
import whisper
import pytube
import requests
def whisperMagic(url):
r = requests.get(url)
status = "Video unavailable" in r.text
if status == False:
data = pytube.YouTube(url)
audio = data.streams.get_audio_only()
audio = audio.download()
model = whisper.load_model('medium')
text = model.transcribe(audio, fp16=False)
text = text['text']
return text
url = input("Please enter the URL of the video: ")
print(whisperMagic(url))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment