diff --git a/Video_Killed_The_Radio_Star_Defusion.ipynb b/Video_Killed_The_Radio_Star_Defusion.ipynb index 34efa00..3bb1173 100644 --- a/Video_Killed_The_Radio_Star_Defusion.ipynb +++ b/Video_Killed_The_Radio_Star_Defusion.ipynb @@ -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", @@ -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", @@ -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", @@ -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", @@ -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",