GPT-3 및 Whisper를 사용하여 모든 언어의 YouTube 동영상 요약 생성 😀
필요한 기술
설정 필요
pip install git+https://github.com/openai/whisper.git
pip install streamlit
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg
코드 작성 시작
import streamlit as st;
import openai
from pytube import YouTube
import whisper
openai.organization = ""
openai.api_key = 'sk-*****kpeKyzuPRIT3Bl***************' # replace with your own key
with st.container():
st.header("Youtube Summary")
st.title("Get the summary of any YouTube video in any language")
yt = YouTube(text_input) ## pass the input url
yt.streams.filter(file_extension='mp3')
stream = yt.streams.get_by_itag(139)
stream.download('',"audio.mp3") ## download the audio
model = whisper.load_model("base") ## load whisper model
result = model.transcribe("audio.mp3") ## start transcribing
content = result["text"] ## store text
response = openai.Completion.create(engine="text-davinci-002",prompt=content + tldr_tag,temperature=0.3,
max_tokens=200,
top_p=1.0, ## calling API to get Summary using GPT engine
frequency_penalty=0,
presence_penalty=0,)
st.subheader("Here is your summary!")
st.write(response["choices"][0]["text"]) ## finally inject result to webapp using streamlit
완전한 소스 코드
import streamlit as st;
import openai
from pytube import YouTube
import whisper
openai.organization = ""
openai.api_key = 'sk-yjfA0s****************1zOhM****lXM'
with st.container():
st.header("Youtube Summary")
st.title("Get the summary of any YouTube video in any language")
## input url of video ##
with st.container():
st.write("---")
text_input = st.text_input(
"Please paste the url of the video 👇",
placeholder="paste the url", # taking url of a YT video
)
if text_input:
try:
with st.spinner('Wait for it...'): ## streamlit loader
tldr_tag = "\n\nTl;dr" ## tag use to tell GPT engine where text is ended
yt = YouTube(text_input) ## pass url as text_input to pytube for for downloading the audio
yt.streams.filter(file_extension='mp3')
stream = yt.streams.get_by_itag(139)
stream.download('',"audio.mp3") ## download the audio and saved as audio.mp3 in same folder
model = whisper.load_model("base") ## load whisper model
result = model.transcribe("audio.mp3") ## start transcribing video into text
content = result["text"] ## store text om content var
st.write(content)
response = openai.Completion.create(engine="text-davinci-002",prompt=content + tldr_tag,temperature=0.3,
max_tokens=200,
top_p=1.0, ## calling API to generate the summary of transcribed text stored in content var
frequency_penalty=0,
presence_penalty=0,
)
st.subheader("Here is your summary!")
st.write(response["choices"][0]["text"]) ## finally inject responsed text into webapp using streamlit function
st.success('Done!')
except:
print("Connection Error")
당신이 그것을 좋아하고 나에게 피드백을 주시기 바랍니다 바랍니다
내 GitHub : link
여기에서 나와 연결할 수 있습니다[email protected].
Reference
이 문제에 관하여(GPT-3 및 Whisper를 사용하여 모든 언어의 YouTube 동영상 요약 생성 😀), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/karankulshrestha/using-gpt-3-and-whisper-to-generate-a-summary-of-a-youtube-video-of-any-language-h9f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)