Skip to content

Commit

Permalink
isolate YouTubeHelper to step 3
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarx committed Oct 2, 2022
1 parent 90bb323 commit 5d3f8ca
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions Video_Killed_The_Radio_Star_Defusion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"# @title # 2. 📋 Audio processing parameters\n",
"\n",
"import datetime as dt\n",
"\n",
"from itertools import chain, cycle\n",
"import json\n",
"import os\n",
"from pathlib import Path\n",
Expand All @@ -161,25 +161,15 @@
"import time\n",
"import warnings\n",
"\n",
"import tokenizations\n",
"import webvtt\n",
"\n",
"from IPython.display import display\n",
"from omegaconf import OmegaConf\n",
"import numpy as np\n",
"\n",
"\n",
"from itertools import chain, cycle\n",
"\n",
"from tqdm.autonotebook import tqdm\n",
"\n",
"from vktrs.youtube import (\n",
" YoutubeHelper,\n",
" parse_timestamp,\n",
" vtt_to_token_timestamps,\n",
" srv2_to_token_timestamps,\n",
")\n",
"import tokenizations\n",
"import webvtt\n",
"\n",
"\n",
"from omegaconf import OmegaConf\n",
"# to do: use project name to name file\n",
"# to do: separate global params defined here from the storyboard object.\n",
"# users will not anticipate that updates here will destroy their work\n",
Expand Down Expand Up @@ -234,6 +224,13 @@
"\n",
"# @title # 3. 📥 Download audio from youtube\n",
"\n",
"from vktrs.youtube import (\n",
" YoutubeHelper,\n",
" parse_timestamp,\n",
" vtt_to_token_timestamps,\n",
" srv2_to_token_timestamps,\n",
")\n",
"\n",
"storyboard_fname = 'storyboard.yaml'\n",
"storyboard = OmegaConf.load(storyboard_fname)\n",
"\n",
Expand All @@ -244,6 +241,10 @@
" if storyboard.params.get('audio_fpath') is None:\n",
" helper = YoutubeHelper(video_url)\n",
"\n",
" # estimate video end\n",
" video_duration = dt.timedelta(seconds=helper.info['duration'])\n",
" storyboard.params['video_duration'] = video_duration.total_seconds()\n",
"\n",
" input_audio = helper.info['requested_downloads'][-1]['filepath']\n",
" !ffmpeg -y -i \"{input_audio}\" -acodec libmp3lame audio.mp3\n",
"\n",
Expand Down Expand Up @@ -332,7 +333,7 @@
"ifps = dt.timedelta(seconds=1/fps)\n",
"\n",
"# estimate video end\n",
"video_duration = dt.timedelta(seconds=helper.info['duration'])\n",
"video_duration = storyboard.params['video_duration']\n",
"\n",
"# dummy prompt for last scene duration\n",
"prompt_starts.append({'td':video_duration})\n",
Expand Down

0 comments on commit 5d3f8ca

Please sign in to comment.