Commit
Β·
3e992b9
1
Parent(s):
4cc4d7c
message
Browse files- .streamlit/config.toml +3 -0
- app.py +75 -0
- requirements.txt +3 -0
- temp.mp3 +0 -0
- testing.ipynb +126 -0
.streamlit/config.toml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[theme]
|
2 |
+
base="dark"
|
3 |
+
primaryColor="purple"
|
app.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import requests
|
3 |
+
import re
|
4 |
+
import openai
|
5 |
+
from pytube import YouTube
|
6 |
+
import os
|
7 |
+
|
8 |
+
# Remove previous audio file
|
9 |
+
audio_filename = "temp.mp3"
|
10 |
+
if os.path.exists(audio_filename):
|
11 |
+
os.remove(audio_filename)
|
12 |
+
|
13 |
+
# Function to check if the provided OpenAI API key is valid
|
14 |
+
def is_valid_openai_key(api_key):
|
15 |
+
try:
|
16 |
+
openai.api_key = api_key
|
17 |
+
openai.Engine.list()
|
18 |
+
return True
|
19 |
+
except Exception as e:
|
20 |
+
st.write(f"Error: {e}")
|
21 |
+
return False
|
22 |
+
|
23 |
+
# Function to check if a provided link is a valid YouTube video link
|
24 |
+
def is_valid_youtube_link(url):
|
25 |
+
youtube_regex = re.compile(
|
26 |
+
r'(https?://)?(www\.)?'
|
27 |
+
r'(youtube|youtu|youtube-nocookie)\.(com|be)/'
|
28 |
+
r'(watch\?v=|embed/|v/|.+\?v=)?([^&=%\?]{11})'
|
29 |
+
)
|
30 |
+
return youtube_regex.match(url) is not None
|
31 |
+
|
32 |
+
# Define the application layout
|
33 |
+
st.set_page_config(page_title="YouTube Video to Text", layout="wide")
|
34 |
+
|
35 |
+
# Add the application header
|
36 |
+
st.title("YouTube Video to Text")
|
37 |
+
|
38 |
+
# Add the side panel
|
39 |
+
with st.sidebar:
|
40 |
+
st.header("Settings")
|
41 |
+
openai_api_key = st.text_input("OpenAI API Key", type="password")
|
42 |
+
youtube_video_link = st.text_input("YouTube Video Link")
|
43 |
+
st.caption('Note: Only videos in english language are currently supported.')
|
44 |
+
|
45 |
+
# In the main section of the app, add the following code:
|
46 |
+
if openai_api_key and youtube_video_link and is_valid_youtube_link(youtube_video_link):
|
47 |
+
if is_valid_openai_key(openai_api_key):
|
48 |
+
# Your code to process the YouTube video using the OpenAI API goes here
|
49 |
+
print(youtube_video_link)
|
50 |
+
youtube_video = YouTube(youtube_video_link, use_oauth=True, allow_oauth_cache=True)
|
51 |
+
st.markdown(f"Title: **{youtube_video.title}**")
|
52 |
+
streams=youtube_video.streams.filter(only_audio=True)
|
53 |
+
stream=streams.last()
|
54 |
+
with st.spinner('Downloading Audio'):
|
55 |
+
stream.download(filename='temp.mp3')
|
56 |
+
audio_file= open("temp.mp3", "rb")
|
57 |
+
with st.spinner('Transcribing Text'):
|
58 |
+
transcript_json = openai.Audio.transcribe("whisper-1", audio_file)
|
59 |
+
transcript = transcript_json["text"]
|
60 |
+
st.markdown("**Text:**")
|
61 |
+
st.markdown(transcript)
|
62 |
+
else:
|
63 |
+
st.warning("Invalid OpenAI API Key. Please enter a valid API key.")
|
64 |
+
else:
|
65 |
+
st.warning("Please enter a valid YouTube video link and OpenAI API key.")
|
66 |
+
|
67 |
+
# Add the footer with the creator's name and GitHub link
|
68 |
+
st.markdown(
|
69 |
+
"""
|
70 |
+
<div style="position: fixed; bottom: 10px; right: 10px; width: auto; height: auto; background-color: white; border: 1px solid #f0f2f6; border-radius: 5px; padding: 1rem;">
|
71 |
+
Created by Taaha Bajwa - <a href="https://github.com/yourusername/yourrepository" target="_blank">Source Code</a>
|
72 |
+
</div>
|
73 |
+
""",
|
74 |
+
unsafe_allow_html=True
|
75 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.17.0
|
2 |
+
openai
|
3 |
+
pytube
|
temp.mp3
ADDED
Binary file (925 kB). View file
|
|
testing.ipynb
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"Collecting youtube-dl\n",
|
13 |
+
" Downloading youtube_dl-2021.12.17-py2.py3-none-any.whl (1.9 MB)\n",
|
14 |
+
"\u001b[2K \u001b[90mββββββββββββββββββββββββββββββββββββββββ\u001b[0m \u001b[32m1.9/1.9 MB\u001b[0m \u001b[31m1.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m0m\n",
|
15 |
+
"\u001b[?25hInstalling collected packages: youtube-dl\n",
|
16 |
+
"Successfully installed youtube-dl-2021.12.17\n",
|
17 |
+
"\u001b[33mWARNING: You are using pip version 22.0.4; however, version 23.1.2 is available.\n",
|
18 |
+
"You should consider upgrading via the '/home/darth/MLAI-projects/whisper-ASR-youtube/envasr/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\u001b[33m\n",
|
19 |
+
"\u001b[0m"
|
20 |
+
]
|
21 |
+
}
|
22 |
+
],
|
23 |
+
"source": [
|
24 |
+
"!pip install youtube-dl"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
{
|
28 |
+
"cell_type": "code",
|
29 |
+
"execution_count": 2,
|
30 |
+
"metadata": {},
|
31 |
+
"outputs": [],
|
32 |
+
"source": [
|
33 |
+
"import youtube_dl\n",
|
34 |
+
"\n",
|
35 |
+
"# Function to download the audio stream from a YouTube video\n",
|
36 |
+
"def download_audio_stream(video_url, output_format=\"mp3\"):\n",
|
37 |
+
" ydl_opts = {\n",
|
38 |
+
" \"format\": \"bestaudio/best\",\n",
|
39 |
+
" \"postprocessors\": [\n",
|
40 |
+
" {\n",
|
41 |
+
" \"key\": \"FFmpegExtractAudio\",\n",
|
42 |
+
" \"preferredcodec\": output_format,\n",
|
43 |
+
" \"preferredquality\": \"192\",\n",
|
44 |
+
" }\n",
|
45 |
+
" ],\n",
|
46 |
+
" \"outtmpl\": \"audio.%(ext)s\",\n",
|
47 |
+
" \"quiet\": True,\n",
|
48 |
+
" }\n",
|
49 |
+
"\n",
|
50 |
+
" with youtube_dl.YoutubeDL(ydl_opts) as ydl:\n",
|
51 |
+
" ydl.download([video_url])"
|
52 |
+
]
|
53 |
+
},
|
54 |
+
{
|
55 |
+
"cell_type": "code",
|
56 |
+
"execution_count": 3,
|
57 |
+
"metadata": {},
|
58 |
+
"outputs": [
|
59 |
+
{
|
60 |
+
"name": "stderr",
|
61 |
+
"output_type": "stream",
|
62 |
+
"text": [
|
63 |
+
"ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n"
|
64 |
+
]
|
65 |
+
},
|
66 |
+
{
|
67 |
+
"ename": "DownloadError",
|
68 |
+
"evalue": "ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
|
69 |
+
"output_type": "error",
|
70 |
+
"traceback": [
|
71 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
72 |
+
"\u001b[0;31mRegexNotFoundError\u001b[0m Traceback (most recent call last)",
|
73 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:815\u001b[0m, in \u001b[0;36mYoutubeDL.__handle_extraction_exceptions.<locals>.wrapper\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 814\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 815\u001b[0m \u001b[39mreturn\u001b[39;00m func(\u001b[39mself\u001b[39;49m, \u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 816\u001b[0m \u001b[39mexcept\u001b[39;00m GeoRestrictedError \u001b[39mas\u001b[39;00m e:\n",
|
74 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:836\u001b[0m, in \u001b[0;36mYoutubeDL.__extract_info\u001b[0;34m(self, url, ie, download, extra_info, process)\u001b[0m\n\u001b[1;32m 834\u001b[0m \u001b[39m@__handle_extraction_exceptions\u001b[39m\n\u001b[1;32m 835\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__extract_info\u001b[39m(\u001b[39mself\u001b[39m, url, ie, download, extra_info, process):\n\u001b[0;32m--> 836\u001b[0m ie_result \u001b[39m=\u001b[39m ie\u001b[39m.\u001b[39;49mextract(url)\n\u001b[1;32m 837\u001b[0m \u001b[39mif\u001b[39;00m ie_result \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m: \u001b[39m# Finished already (backwards compatibility; listformats and friends should be moved here)\u001b[39;00m\n",
|
75 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/extractor/common.py:534\u001b[0m, in \u001b[0;36mInfoExtractor.extract\u001b[0;34m(self, url)\u001b[0m\n\u001b[1;32m 533\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39minitialize()\n\u001b[0;32m--> 534\u001b[0m ie_result \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_real_extract(url)\n\u001b[1;32m 535\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_x_forwarded_for_ip:\n",
|
76 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/extractor/youtube.py:1794\u001b[0m, in \u001b[0;36mYoutubeIE._real_extract\u001b[0;34m(self, url)\u001b[0m\n\u001b[1;32m 1782\u001b[0m owner_profile_url \u001b[39m=\u001b[39m microformat\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mownerProfileUrl\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[1;32m 1784\u001b[0m info \u001b[39m=\u001b[39m {\n\u001b[1;32m 1785\u001b[0m \u001b[39m'\u001b[39m\u001b[39mid\u001b[39m\u001b[39m'\u001b[39m: video_id,\n\u001b[1;32m 1786\u001b[0m \u001b[39m'\u001b[39m\u001b[39mtitle\u001b[39m\u001b[39m'\u001b[39m: \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_live_title(video_title) \u001b[39mif\u001b[39;00m is_live \u001b[39melse\u001b[39;00m video_title,\n\u001b[1;32m 1787\u001b[0m \u001b[39m'\u001b[39m\u001b[39mformats\u001b[39m\u001b[39m'\u001b[39m: formats,\n\u001b[1;32m 1788\u001b[0m \u001b[39m'\u001b[39m\u001b[39mthumbnails\u001b[39m\u001b[39m'\u001b[39m: thumbnails,\n\u001b[1;32m 1789\u001b[0m \u001b[39m'\u001b[39m\u001b[39mdescription\u001b[39m\u001b[39m'\u001b[39m: video_description,\n\u001b[1;32m 1790\u001b[0m \u001b[39m'\u001b[39m\u001b[39mupload_date\u001b[39m\u001b[39m'\u001b[39m: unified_strdate(\n\u001b[1;32m 1791\u001b[0m microformat\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39muploadDate\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[1;32m 1792\u001b[0m \u001b[39mor\u001b[39;00m search_meta(\u001b[39m'\u001b[39m\u001b[39muploadDate\u001b[39m\u001b[39m'\u001b[39m)),\n\u001b[1;32m 1793\u001b[0m \u001b[39m'\u001b[39m\u001b[39muploader\u001b[39m\u001b[39m'\u001b[39m: video_details[\u001b[39m'\u001b[39m\u001b[39mauthor\u001b[39m\u001b[39m'\u001b[39m],\n\u001b[0;32m-> 1794\u001b[0m \u001b[39m'\u001b[39m\u001b[39muploader_id\u001b[39m\u001b[39m'\u001b[39m: \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_search_regex(\u001b[39mr\u001b[39;49m\u001b[39m'\u001b[39;49m\u001b[39m/(?:channel|user)/([^/?&#]+)\u001b[39;49m\u001b[39m'\u001b[39;49m, owner_profile_url, \u001b[39m'\u001b[39;49m\u001b[39muploader id\u001b[39;49m\u001b[39m'\u001b[39;49m) \u001b[39mif\u001b[39;00m owner_profile_url \u001b[39melse\u001b[39;00m \u001b[39mNone\u001b[39;00m,\n\u001b[1;32m 1795\u001b[0m \u001b[39m'\u001b[39m\u001b[39muploader_url\u001b[39m\u001b[39m'\u001b[39m: owner_profile_url,\n\u001b[1;32m 1796\u001b[0m \u001b[39m'\u001b[39m\u001b[39mchannel_id\u001b[39m\u001b[39m'\u001b[39m: channel_id,\n\u001b[1;32m 1797\u001b[0m \u001b[39m'\u001b[39m\u001b[39mchannel_url\u001b[39m\u001b[39m'\u001b[39m: \u001b[39m'\u001b[39m\u001b[39mhttps://www.youtube.com/channel/\u001b[39m\u001b[39m'\u001b[39m \u001b[39m+\u001b[39m channel_id \u001b[39mif\u001b[39;00m channel_id \u001b[39melse\u001b[39;00m \u001b[39mNone\u001b[39;00m,\n\u001b[1;32m 1798\u001b[0m \u001b[39m'\u001b[39m\u001b[39mduration\u001b[39m\u001b[39m'\u001b[39m: duration,\n\u001b[1;32m 1799\u001b[0m \u001b[39m'\u001b[39m\u001b[39mview_count\u001b[39m\u001b[39m'\u001b[39m: int_or_none(\n\u001b[1;32m 1800\u001b[0m video_details\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mviewCount\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[1;32m 1801\u001b[0m \u001b[39mor\u001b[39;00m microformat\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39mviewCount\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[1;32m 1802\u001b[0m \u001b[39mor\u001b[39;00m search_meta(\u001b[39m'\u001b[39m\u001b[39minteractionCount\u001b[39m\u001b[39m'\u001b[39m)),\n\u001b[1;32m 1803\u001b[0m \u001b[39m'\u001b[39m\u001b[39maverage_rating\u001b[39m\u001b[39m'\u001b[39m: float_or_none(video_details\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39maverageRating\u001b[39m\u001b[39m'\u001b[39m)),\n\u001b[1;32m 1804\u001b[0m \u001b[39m'\u001b[39m\u001b[39mage_limit\u001b[39m\u001b[39m'\u001b[39m: \u001b[39m18\u001b[39m \u001b[39mif\u001b[39;00m (\n\u001b[1;32m 1805\u001b[0m microformat\u001b[39m.\u001b[39mget(\u001b[39m'\u001b[39m\u001b[39misFamilySafe\u001b[39m\u001b[39m'\u001b[39m) \u001b[39mis\u001b[39;00m \u001b[39mFalse\u001b[39;00m\n\u001b[1;32m 1806\u001b[0m \u001b[39mor\u001b[39;00m search_meta(\u001b[39m'\u001b[39m\u001b[39misFamilyFriendly\u001b[39m\u001b[39m'\u001b[39m) \u001b[39m==\u001b[39m \u001b[39m'\u001b[39m\u001b[39mfalse\u001b[39m\u001b[39m'\u001b[39m\n\u001b[1;32m 1807\u001b[0m \u001b[39mor\u001b[39;00m search_meta(\u001b[39m'\u001b[39m\u001b[39mog:restrictions:age\u001b[39m\u001b[39m'\u001b[39m) \u001b[39m==\u001b[39m \u001b[39m'\u001b[39m\u001b[39m18+\u001b[39m\u001b[39m'\u001b[39m) \u001b[39melse\u001b[39;00m \u001b[39m0\u001b[39m,\n\u001b[1;32m 1808\u001b[0m \u001b[39m'\u001b[39m\u001b[39mwebpage_url\u001b[39m\u001b[39m'\u001b[39m: webpage_url,\n\u001b[1;32m 1809\u001b[0m \u001b[39m'\u001b[39m\u001b[39mcategories\u001b[39m\u001b[39m'\u001b[39m: [category] \u001b[39mif\u001b[39;00m category \u001b[39melse\u001b[39;00m \u001b[39mNone\u001b[39;00m,\n\u001b[1;32m 1810\u001b[0m \u001b[39m'\u001b[39m\u001b[39mtags\u001b[39m\u001b[39m'\u001b[39m: keywords,\n\u001b[1;32m 1811\u001b[0m \u001b[39m'\u001b[39m\u001b[39mis_live\u001b[39m\u001b[39m'\u001b[39m: is_live,\n\u001b[1;32m 1812\u001b[0m }\n\u001b[1;32m 1814\u001b[0m pctr \u001b[39m=\u001b[39m try_get(\n\u001b[1;32m 1815\u001b[0m player_response,\n\u001b[1;32m 1816\u001b[0m \u001b[39mlambda\u001b[39;00m x: x[\u001b[39m'\u001b[39m\u001b[39mcaptions\u001b[39m\u001b[39m'\u001b[39m][\u001b[39m'\u001b[39m\u001b[39mplayerCaptionsTracklistRenderer\u001b[39m\u001b[39m'\u001b[39m], \u001b[39mdict\u001b[39m)\n",
|
77 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/extractor/common.py:1012\u001b[0m, in \u001b[0;36mInfoExtractor._search_regex\u001b[0;34m(self, pattern, string, name, default, fatal, flags, group)\u001b[0m\n\u001b[1;32m 1011\u001b[0m \u001b[39melif\u001b[39;00m fatal:\n\u001b[0;32m-> 1012\u001b[0m \u001b[39mraise\u001b[39;00m RegexNotFoundError(\u001b[39m'\u001b[39m\u001b[39mUnable to extract \u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m'\u001b[39m \u001b[39m%\u001b[39m _name)\n\u001b[1;32m 1013\u001b[0m \u001b[39melse\u001b[39;00m:\n",
|
78 |
+
"\u001b[0;31mRegexNotFoundError\u001b[0m: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.",
|
79 |
+
"\nDuring handling of the above exception, another exception occurred:\n",
|
80 |
+
"\u001b[0;31mDownloadError\u001b[0m Traceback (most recent call last)",
|
81 |
+
"Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m download_audio_stream(\u001b[39m'\u001b[39;49m\u001b[39mhttps://www.youtube.com/watch?v=IvjyvmYmeKY\u001b[39;49m\u001b[39m'\u001b[39;49m)\n",
|
82 |
+
"Cell \u001b[0;32mIn[2], line 19\u001b[0m, in \u001b[0;36mdownload_audio_stream\u001b[0;34m(video_url, output_format)\u001b[0m\n\u001b[1;32m 5\u001b[0m ydl_opts \u001b[39m=\u001b[39m {\n\u001b[1;32m 6\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mformat\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39m\"\u001b[39m\u001b[39mbestaudio/best\u001b[39m\u001b[39m\"\u001b[39m,\n\u001b[1;32m 7\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mpostprocessors\u001b[39m\u001b[39m\"\u001b[39m: [\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mquiet\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39mTrue\u001b[39;00m,\n\u001b[1;32m 16\u001b[0m }\n\u001b[1;32m 18\u001b[0m \u001b[39mwith\u001b[39;00m youtube_dl\u001b[39m.\u001b[39mYoutubeDL(ydl_opts) \u001b[39mas\u001b[39;00m ydl:\n\u001b[0;32m---> 19\u001b[0m ydl\u001b[39m.\u001b[39;49mdownload([video_url])\n",
|
83 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:2068\u001b[0m, in \u001b[0;36mYoutubeDL.download\u001b[0;34m(self, url_list)\u001b[0m\n\u001b[1;32m 2065\u001b[0m \u001b[39mfor\u001b[39;00m url \u001b[39min\u001b[39;00m url_list:\n\u001b[1;32m 2066\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m 2067\u001b[0m \u001b[39m# It also downloads the videos\u001b[39;00m\n\u001b[0;32m-> 2068\u001b[0m res \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mextract_info(\n\u001b[1;32m 2069\u001b[0m url, force_generic_extractor\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mparams\u001b[39m.\u001b[39;49mget(\u001b[39m'\u001b[39;49m\u001b[39mforce_generic_extractor\u001b[39;49m\u001b[39m'\u001b[39;49m, \u001b[39mFalse\u001b[39;49;00m))\n\u001b[1;32m 2070\u001b[0m \u001b[39mexcept\u001b[39;00m UnavailableVideoError:\n\u001b[1;32m 2071\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mreport_error(\u001b[39m'\u001b[39m\u001b[39munable to download video\u001b[39m\u001b[39m'\u001b[39m)\n",
|
84 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:808\u001b[0m, in \u001b[0;36mYoutubeDL.extract_info\u001b[0;34m(self, url, download, ie_key, extra_info, process, force_generic_extractor)\u001b[0m\n\u001b[1;32m 804\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m ie\u001b[39m.\u001b[39mworking():\n\u001b[1;32m 805\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mreport_warning(\u001b[39m'\u001b[39m\u001b[39mThe program functionality for this site has been marked as broken, \u001b[39m\u001b[39m'\u001b[39m\n\u001b[1;32m 806\u001b[0m \u001b[39m'\u001b[39m\u001b[39mand will probably not work.\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[0;32m--> 808\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m__extract_info(url, ie, download, extra_info, process)\n\u001b[1;32m 809\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 810\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mreport_error(\u001b[39m'\u001b[39m\u001b[39mno suitable InfoExtractor for URL \u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m'\u001b[39m \u001b[39m%\u001b[39m url)\n",
|
85 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:824\u001b[0m, in \u001b[0;36mYoutubeDL.__handle_extraction_exceptions.<locals>.wrapper\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 822\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mreport_error(msg)\n\u001b[1;32m 823\u001b[0m \u001b[39mexcept\u001b[39;00m ExtractorError \u001b[39mas\u001b[39;00m e: \u001b[39m# An error we somewhat expected\u001b[39;00m\n\u001b[0;32m--> 824\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mreport_error(compat_str(e), e\u001b[39m.\u001b[39;49mformat_traceback())\n\u001b[1;32m 825\u001b[0m \u001b[39mexcept\u001b[39;00m MaxDownloadsReached:\n\u001b[1;32m 826\u001b[0m \u001b[39mraise\u001b[39;00m\n",
|
86 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:628\u001b[0m, in \u001b[0;36mYoutubeDL.report_error\u001b[0;34m(self, message, tb)\u001b[0m\n\u001b[1;32m 626\u001b[0m _msg_header \u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39mERROR:\u001b[39m\u001b[39m'\u001b[39m\n\u001b[1;32m 627\u001b[0m error_message \u001b[39m=\u001b[39m \u001b[39m'\u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m \u001b[39m\u001b[39m%s\u001b[39;00m\u001b[39m'\u001b[39m \u001b[39m%\u001b[39m (_msg_header, message)\n\u001b[0;32m--> 628\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mtrouble(error_message, tb)\n",
|
87 |
+
"File \u001b[0;32m~/MLAI-projects/whisper-ASR-youtube/envasr/lib/python3.9/site-packages/youtube_dl/YoutubeDL.py:598\u001b[0m, in \u001b[0;36mYoutubeDL.trouble\u001b[0;34m(self, message, tb)\u001b[0m\n\u001b[1;32m 596\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 597\u001b[0m exc_info \u001b[39m=\u001b[39m sys\u001b[39m.\u001b[39mexc_info()\n\u001b[0;32m--> 598\u001b[0m \u001b[39mraise\u001b[39;00m DownloadError(message, exc_info)\n\u001b[1;32m 599\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_download_retcode \u001b[39m=\u001b[39m \u001b[39m1\u001b[39m\n",
|
88 |
+
"\u001b[0;31mDownloadError\u001b[0m: ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see https://yt-dl.org/update on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output."
|
89 |
+
]
|
90 |
+
}
|
91 |
+
],
|
92 |
+
"source": [
|
93 |
+
"download_audio_stream('https://www.youtube.com/watch?v=IvjyvmYmeKY')"
|
94 |
+
]
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"cell_type": "code",
|
98 |
+
"execution_count": null,
|
99 |
+
"metadata": {},
|
100 |
+
"outputs": [],
|
101 |
+
"source": []
|
102 |
+
}
|
103 |
+
],
|
104 |
+
"metadata": {
|
105 |
+
"kernelspec": {
|
106 |
+
"display_name": "envasr",
|
107 |
+
"language": "python",
|
108 |
+
"name": "python3"
|
109 |
+
},
|
110 |
+
"language_info": {
|
111 |
+
"codemirror_mode": {
|
112 |
+
"name": "ipython",
|
113 |
+
"version": 3
|
114 |
+
},
|
115 |
+
"file_extension": ".py",
|
116 |
+
"mimetype": "text/x-python",
|
117 |
+
"name": "python",
|
118 |
+
"nbconvert_exporter": "python",
|
119 |
+
"pygments_lexer": "ipython3",
|
120 |
+
"version": "3.9.13"
|
121 |
+
},
|
122 |
+
"orig_nbformat": 4
|
123 |
+
},
|
124 |
+
"nbformat": 4,
|
125 |
+
"nbformat_minor": 2
|
126 |
+
}
|