From c6d702062b1735de5a8210243de17048947ed0fb Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 12:48:46 -0700 Subject: [PATCH 1/9] reformatting --- bleep_that_sht/gradio_app_url_download.py | 204 ++++++++++++++++++ ...nload.py => streamlit_app_url_download.py} | 0 ...pload.py => streamlit_app_video_upload.py} | 0 3 files changed, 204 insertions(+) create mode 100644 bleep_that_sht/gradio_app_url_download.py rename bleep_that_sht/{app_url_download.py => streamlit_app_url_download.py} (100%) rename bleep_that_sht/{app_video_upload.py => streamlit_app_video_upload.py} (100%) diff --git a/bleep_that_sht/gradio_app_url_download.py b/bleep_that_sht/gradio_app_url_download.py new file mode 100644 index 0000000..d42ee91 --- /dev/null +++ b/bleep_that_sht/gradio_app_url_download.py @@ -0,0 +1,204 @@ +from bleep_that_sht import main_dir +from bleep_that_sht.transcribe import avaliable_models +from bleep_that_sht.transcribe import transcribe +from bleep_that_sht.audio_extractor import extract_audio +from bleep_that_sht.create import bleep_replace +from bleep_that_sht.yt_download import download_video +import tempfile +import uuid +import os +import io +import gradio as gr + + +HF_TOKEN = None + +try: + HF_TOKEN = os.environ.get("HF_TOKEN") +except: + pass + + +print("Setting up Gradio interface...") +with gr.Blocks(theme=gr.themes.Soft(), title="🎬 Bleep That Sh*t 🙊") as demo: + with gr.Tabs(): + with gr.TabItem("🎬 Bleep That Sh*t 🙊"): + with gr.Row(): + with gr.Column(scale=4): + url_input = gr.Textbox( + value="https://www.youtube.com/shorts/43BhDHYBG0o", + label="🔗 Paste YouTube / Shorts URL here", + placeholder="e.g., https://www.youtube.com/watch?v=.", + max_lines=1, + ) + + with gr.Row(): + with gr.Column(scale=8): + bleep_words = gr.Textbox( + placeholder="bleep keywords go here separated by commas", + label="bleep-word list", + value="treetz, ice, cream, chocolate, syrup, cookie, hooked, threats, treats, trees", + ) + with gr.Column(scale=3): + gr.Dropdown(choices=avaliable_models, value=1, label="whisper model (base only in HF space)", info="whisper model selection") + with gr.Column(scale=4): + just_transcribe_button = gr.Button("Just Transcribe", variant="primary") + bleep_transcribe_button = gr.Button("Transcribe & Bleep", variant="primary") + + with gr.Row(): + transcript_output = gr.Textbox(label="Video Transcript", placeholder="", max_lines=5, show_copy_button=True) + + with gr.Row(): + og_video = gr.Video( + show_download_button=True, + show_label=True, + label="original video", + format="mp4", + visible=True, + width="50vw", + height="50vw", + ) + + bleep_video = gr.Video( + show_download_button=True, + show_label=True, + label="bleeped video", + format="mp4", + visible=True, + width="50vw", + height="50vw", + ) + + @just_transcribe_button.click(inputs=[url_input], outputs=[og_video, transcript_output]) + def just_transcribe(): + with tempfile.TemporaryDirectory() as tmpdirname: + temporary_video_location = tmpdirname + "/original_" + str(uuid.uuid4()) + ".mp4" + download_video(url_input, temporary_video_location) + filename = open(temporary_video_location, "rb") + byte_file = io.BytesIO(filename.read()) + with open(temporary_video_location, "wb") as out: + out.write(byte_file.read()) + og_video.value = out + + with gr.Tab("💡 About"): + with gr.Blocks() as about: + gr.Markdown( + ( + "### Bleep out words of your choice from an input video. \n" + "How it works: \n\n" + "1. Provided a youtube / shorts url \n" + "2. Choose your your desired bleep keywords \n" + "3. (if running locally) Choose a model from the Whisper family to transcribe the audio (defaults to base only for HF space) \n" + "4. (optional) Press 'Just Transcribe' to examine / download just the transcription of the video (can help in choosing bleep words) \n" + "5. Press 'Transcribe and bleep' to transcribe and replace all instances of your keywords with *beep* sounds \n\n" + "If you want to select your Whisper model / run longer videos pull and run the app locally. \n\n" + "Notice: baseline (not fine tuned) Whisper models are used here - you may need to be creative to bleep out all the versions of an input word you want depending on its transcription. \n\n" + "You do *not* need a GPU to run this locally. Larger models take more time to process locally, but its doable. \n" + ) + ) + + # print(f"local_file_path --> {local_file_path}") + + # if local_file_path is not None: + # og_video = gr.PlayableVideo( + # value=local_file_path, + # show_download_button=True, + # show_label=True, + # label="bleeped video", + # visible=True + # ) + + # with gr.Row(): + # with gr.Column(): + # bleep_words = gr.Textbox( + # placeholder="bleep keywords go here separated by commas", + # label="bleep-word list", + # value="treetz, ice, cream, chocolate, syrup, cookie, hooked, threats, treats", + # ) + + # with gr.Column(): + # model_selection = gr.Dropdown( + # avaliable_models, + # label="base", + # info="Whisper models - small to large", + # ) + + # just_transcribe_button = gr.Button("Just Transcribe", variant="primary") + # bleep_transcribe_button = gr.Button("Transcribe & Bleep", variant="primary") + + # with gr.Column(): + # transcription_output = gr.Textbox( + # label="Transcription", lines=10, show_copy_button=True + # ) + # with gr.Column(): + # timestamped_transcription_output = gr.Textbox( + # label="Timestamped Transcription", lines=10, show_copy_button=True + # ) + + # with gr.Column(): + # og_video = gr.PlayableVideo( + # value=None, + # show_download_button=True, + # show_label=True, + # label="bleeped video", + # ) + + # with tempfile.TemporaryDirectory() as tmpdirname: + # temporary_video_location = tmpdirname + "/" + "original.mp4" + # temporary_audio_location = temporary_video_location.replace("mp4", "mp3") + + # bleep_video_output = temporary_video_location.replace("original", "bleep") + # bleep_audio_output = bleep_video_output.replace("mp4", "mp3") + + # def download(url: str, + # tmpdirname: str) -> str | None: + # if len(url) > 0: + # local_file_path = download_video(url, tmpdirname) + # return local_file_path + # else: + # return None + + # just_transcribe_button.click( + # just_transcribe, + # inputs=[ + # temporary_video_location, + # temporary_audio_location, + # model_selection, + # ], + # outputs=[transcription_output, timestamped_transcription_output], + # ) + + # with gr.Column(): + # bleep_video = gr.PlayableVideo( + # value=bleep_video_output, + # show_download_button=True, + # show_label=True, + # label="bleeped video", + # ) + + # just_transcribe_button.click( + # just_transcribe, + # inputs=[ + # temporary_video_location, + # temporary_audio_location, + # model_selection, + # ], + # outputs=[transcription_output, timestamped_transcription_output], + # ) + + # bleep_transcribe_button.click( + # transcribe_and_bleep, + # inputs=[ + # temporary_video_location, + # temporary_audio_location, + # bleep_video_output, + # bleep_audio_output, + # model_selection, + # bleep_words, + # ], + # outputs=[transcription_output, timestamped_transcription_output], + # ) + +if __name__ == "__main__": + print("Launching Gradio interface...") + demo.launch() diff --git a/bleep_that_sht/app_url_download.py b/bleep_that_sht/streamlit_app_url_download.py similarity index 100% rename from bleep_that_sht/app_url_download.py rename to bleep_that_sht/streamlit_app_url_download.py diff --git a/bleep_that_sht/app_video_upload.py b/bleep_that_sht/streamlit_app_video_upload.py similarity index 100% rename from bleep_that_sht/app_video_upload.py rename to bleep_that_sht/streamlit_app_video_upload.py From ba0b76e3648d34e83d93f22bf913cce64c69fc03 Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 13:46:15 -0700 Subject: [PATCH 2/9] reformatting --- bleep_that_sht/gradio_app_url_download.py | 12 +++++----- bleep_that_sht/yt_download.py | 27 +++++++++-------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/bleep_that_sht/gradio_app_url_download.py b/bleep_that_sht/gradio_app_url_download.py index d42ee91..c034ea2 100644 --- a/bleep_that_sht/gradio_app_url_download.py +++ b/bleep_that_sht/gradio_app_url_download.py @@ -48,7 +48,6 @@ with gr.Row(): transcript_output = gr.Textbox(label="Video Transcript", placeholder="", max_lines=5, show_copy_button=True) - with gr.Row(): og_video = gr.Video( show_download_button=True, show_label=True, @@ -58,7 +57,7 @@ width="50vw", height="50vw", ) - + bleep_video = gr.Video( show_download_button=True, show_label=True, @@ -69,8 +68,9 @@ height="50vw", ) - @just_transcribe_button.click(inputs=[url_input], outputs=[og_video, transcript_output]) - def just_transcribe(): + + @just_transcribe_button.click(inputs=[url_input, transcript_output], outputs=[og_video, transcript_output]) + def just_transcribe(url_input, transcript_output): with tempfile.TemporaryDirectory() as tmpdirname: temporary_video_location = tmpdirname + "/original_" + str(uuid.uuid4()) + ".mp4" download_video(url_input, temporary_video_location) @@ -78,7 +78,9 @@ def just_transcribe(): byte_file = io.BytesIO(filename.read()) with open(temporary_video_location, "wb") as out: out.write(byte_file.read()) - og_video.value = out + og_video.value = temporary_video_location + + transcript_output = "" with gr.Tab("💡 About"): with gr.Blocks() as about: diff --git a/bleep_that_sht/yt_download.py b/bleep_that_sht/yt_download.py index a31ab0c..f51e670 100644 --- a/bleep_that_sht/yt_download.py +++ b/bleep_that_sht/yt_download.py @@ -1,4 +1,6 @@ -from pytube import YouTube +# from pytube import YouTube + +import yt_dlp import re @@ -15,21 +17,14 @@ def download_video(url: str, savepath: str, my_proxies: dict = {}) -> None: try: print("Downloading video from youtube...") if is_valid_youtube_url(url): - yt = YouTube(url, proxies=my_proxies) - audio_video_streams = ( - yt.streams.filter( - file_extension="mp4", - only_audio=False, - only_video=False, - progressive=True, - type="video", - ) - .order_by("resolution") - .asc() - ) - audio_video_itags = [v.itag for v in audio_video_streams] - first_choice_itag = audio_video_itags[0] - yt.streams.get_by_itag(first_choice_itag).download(filename=savepath) + ydl_opts = { + 'format': 'bestvideo[height<=720]+bestaudio/best', + 'merge_output_format': 'mp4', + 'outtmpl': savepath, + } + with yt_dlp.YoutubeDL(ydl_opts) as ydl: + ydl.download([url]) + print("...done!") else: raise ValueError(f"invalid input url: {url}") From def00b94c4d8ece38c4f685eb49a68fe0d7f0d30 Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 15:00:39 -0700 Subject: [PATCH 3/9] reformatting --- bleep_that_sht/gradio_app_url_download.py | 68 +++++++++++++---------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/bleep_that_sht/gradio_app_url_download.py b/bleep_that_sht/gradio_app_url_download.py index c034ea2..7796a20 100644 --- a/bleep_that_sht/gradio_app_url_download.py +++ b/bleep_that_sht/gradio_app_url_download.py @@ -45,42 +45,54 @@ just_transcribe_button = gr.Button("Just Transcribe", variant="primary") bleep_transcribe_button = gr.Button("Transcribe & Bleep", variant="primary") - with gr.Row(): - transcript_output = gr.Textbox(label="Video Transcript", placeholder="", max_lines=5, show_copy_button=True) - - og_video = gr.Video( - show_download_button=True, - show_label=True, - label="original video", - format="mp4", - visible=True, - width="50vw", - height="50vw", - ) - - bleep_video = gr.Video( - show_download_button=True, - show_label=True, - label="bleeped video", - format="mp4", - visible=True, - width="50vw", - height="50vw", - ) - + with tempfile.TemporaryDirectory() as tmpdirname: + with gr.Row(): + transcript_output = gr.Textbox(label="Video Transcript", placeholder="", max_lines=5, show_copy_button=True) + + with gr.Row(): + og_video = gr.Video( + show_download_button=True, + show_label=True, + label="original video", + format="mp4", + visible=True, + width="50vw", + height="50vw", + ) + + bleep_video = gr.Video( + show_download_button=True, + show_label=True, + label="bleeped video", + format="mp4", + visible=True, + width="50vw", + height="50vw", + ) - @just_transcribe_button.click(inputs=[url_input, transcript_output], outputs=[og_video, transcript_output]) - def just_transcribe(url_input, transcript_output): - with tempfile.TemporaryDirectory() as tmpdirname: + @just_transcribe_button.click(inputs=[url_input], outputs=[og_video, transcript_output]) + def just_transcribe(url_input): temporary_video_location = tmpdirname + "/original_" + str(uuid.uuid4()) + ".mp4" download_video(url_input, temporary_video_location) filename = open(temporary_video_location, "rb") byte_file = io.BytesIO(filename.read()) with open(temporary_video_location, "wb") as out: out.write(byte_file.read()) - og_video.value = temporary_video_location - + + new_video = gr.Video( + value=temporary_video_location, + show_download_button=True, + show_label=True, + label="original video", + format="mp4", + visible=True, + width="50vw", + height="50vw", + ) + transcript_output = "" + return new_video, transcript_output + with gr.Tab("💡 About"): with gr.Blocks() as about: From 9f86c55293aa1fb3769361c4eac5e0967d871157 Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 15:04:20 -0700 Subject: [PATCH 4/9] tabs re-added --- bleep_that_sht/gradio_app_url_download.py | 143 +++------------------- 1 file changed, 20 insertions(+), 123 deletions(-) diff --git a/bleep_that_sht/gradio_app_url_download.py b/bleep_that_sht/gradio_app_url_download.py index 7796a20..e8f76a5 100644 --- a/bleep_that_sht/gradio_app_url_download.py +++ b/bleep_that_sht/gradio_app_url_download.py @@ -40,7 +40,7 @@ value="treetz, ice, cream, chocolate, syrup, cookie, hooked, threats, treats, trees", ) with gr.Column(scale=3): - gr.Dropdown(choices=avaliable_models, value=1, label="whisper model (base only in HF space)", info="whisper model selection") + gr.Dropdown(choices=avaliable_models, value="base", label="whisper model (base only in HF space)", info="whisper model selection") with gr.Column(scale=4): just_transcribe_button = gr.Button("Just Transcribe", variant="primary") bleep_transcribe_button = gr.Button("Transcribe & Bleep", variant="primary") @@ -51,21 +51,21 @@ with gr.Row(): og_video = gr.Video( + visible=False, show_download_button=True, show_label=True, label="original video", format="mp4", - visible=True, width="50vw", height="50vw", ) bleep_video = gr.Video( + visible=False, show_download_button=True, show_label=True, label="bleeped video", format="mp4", - visible=True, width="50vw", height="50vw", ) @@ -81,137 +81,34 @@ def just_transcribe(url_input): new_video = gr.Video( value=temporary_video_location, + visible=True, show_download_button=True, show_label=True, label="original video", format="mp4", - visible=True, width="50vw", height="50vw", ) transcript_output = "" return new_video, transcript_output - - - with gr.Tab("💡 About"): - with gr.Blocks() as about: - gr.Markdown( - ( - "### Bleep out words of your choice from an input video. \n" - "How it works: \n\n" - "1. Provided a youtube / shorts url \n" - "2. Choose your your desired bleep keywords \n" - "3. (if running locally) Choose a model from the Whisper family to transcribe the audio (defaults to base only for HF space) \n" - "4. (optional) Press 'Just Transcribe' to examine / download just the transcription of the video (can help in choosing bleep words) \n" - "5. Press 'Transcribe and bleep' to transcribe and replace all instances of your keywords with *beep* sounds \n\n" - "If you want to select your Whisper model / run longer videos pull and run the app locally. \n\n" - "Notice: baseline (not fine tuned) Whisper models are used here - you may need to be creative to bleep out all the versions of an input word you want depending on its transcription. \n\n" - "You do *not* need a GPU to run this locally. Larger models take more time to process locally, but its doable. \n" + + with gr.TabItem("💡 About"): + with gr.Blocks() as about: + gr.Markdown( + ( + "### Bleep out words of your choice from an input video. \n" + "How it works: \n\n" + "1. Provided a youtube / shorts url \n" + "2. Choose your your desired bleep keywords \n" + "3. (if running locally) Choose a model from the Whisper family to transcribe the audio (defaults to base only for HF space) \n" + "4. (optional) Press 'Just Transcribe' to examine / download just the transcription of the video (can help in choosing bleep words) \n" + "5. Press 'Transcribe and bleep' to transcribe and replace all instances of your keywords with *beep* sounds \n\n" + "If you want to select your Whisper model / run longer videos pull and run the app locally. \n\n" + "Notice: baseline (not fine tuned) Whisper models are used here - you may need to be creative to bleep out all the versions of an input word you want depending on its transcription. \n\n" + "You do *not* need a GPU to run this locally. Larger models take more time to process locally, but its doable. \n" + ) ) - ) - - # print(f"local_file_path --> {local_file_path}") - - # if local_file_path is not None: - # og_video = gr.PlayableVideo( - # value=local_file_path, - # show_download_button=True, - # show_label=True, - # label="bleeped video", - # visible=True - # ) - - # with gr.Row(): - # with gr.Column(): - # bleep_words = gr.Textbox( - # placeholder="bleep keywords go here separated by commas", - # label="bleep-word list", - # value="treetz, ice, cream, chocolate, syrup, cookie, hooked, threats, treats", - # ) - - # with gr.Column(): - # model_selection = gr.Dropdown( - # avaliable_models, - # label="base", - # info="Whisper models - small to large", - # ) - - # just_transcribe_button = gr.Button("Just Transcribe", variant="primary") - # bleep_transcribe_button = gr.Button("Transcribe & Bleep", variant="primary") - - # with gr.Column(): - # transcription_output = gr.Textbox( - # label="Transcription", lines=10, show_copy_button=True - # ) - # with gr.Column(): - # timestamped_transcription_output = gr.Textbox( - # label="Timestamped Transcription", lines=10, show_copy_button=True - # ) - - # with gr.Column(): - # og_video = gr.PlayableVideo( - # value=None, - # show_download_button=True, - # show_label=True, - # label="bleeped video", - # ) - - # with tempfile.TemporaryDirectory() as tmpdirname: - # temporary_video_location = tmpdirname + "/" + "original.mp4" - # temporary_audio_location = temporary_video_location.replace("mp4", "mp3") - - # bleep_video_output = temporary_video_location.replace("original", "bleep") - # bleep_audio_output = bleep_video_output.replace("mp4", "mp3") - - # def download(url: str, - # tmpdirname: str) -> str | None: - # if len(url) > 0: - # local_file_path = download_video(url, tmpdirname) - # return local_file_path - # else: - # return None - - # just_transcribe_button.click( - # just_transcribe, - # inputs=[ - # temporary_video_location, - # temporary_audio_location, - # model_selection, - # ], - # outputs=[transcription_output, timestamped_transcription_output], - # ) - - # with gr.Column(): - # bleep_video = gr.PlayableVideo( - # value=bleep_video_output, - # show_download_button=True, - # show_label=True, - # label="bleeped video", - # ) - - # just_transcribe_button.click( - # just_transcribe, - # inputs=[ - # temporary_video_location, - # temporary_audio_location, - # model_selection, - # ], - # outputs=[transcription_output, timestamped_transcription_output], - # ) - - # bleep_transcribe_button.click( - # transcribe_and_bleep, - # inputs=[ - # temporary_video_location, - # temporary_audio_location, - # bleep_video_output, - # bleep_audio_output, - # model_selection, - # bleep_words, - # ], - # outputs=[transcription_output, timestamped_transcription_output], - # ) if __name__ == "__main__": print("Launching Gradio interface...") From 8880aa6638f8a7e91973f3af7625aed61f07749d Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 15:46:19 -0700 Subject: [PATCH 5/9] script complete --- bleep_that_sht/create.py | 1 + bleep_that_sht/gradio_app_url_download.py | 88 ++++++++++++++++++++--- 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/bleep_that_sht/create.py b/bleep_that_sht/create.py index e8605b8..c8c3514 100644 --- a/bleep_that_sht/create.py +++ b/bleep_that_sht/create.py @@ -33,6 +33,7 @@ def bleep_replace( bleep_words: list, timestamped_transcript: dict, ) -> None: + # # extract and save audio from original video # extract_audio(local_file_path=og_video_path, audio_filepath=og_audio_path) diff --git a/bleep_that_sht/gradio_app_url_download.py b/bleep_that_sht/gradio_app_url_download.py index e8f76a5..6f3c463 100644 --- a/bleep_that_sht/gradio_app_url_download.py +++ b/bleep_that_sht/gradio_app_url_download.py @@ -40,10 +40,10 @@ value="treetz, ice, cream, chocolate, syrup, cookie, hooked, threats, treats, trees", ) with gr.Column(scale=3): - gr.Dropdown(choices=avaliable_models, value="base", label="whisper model (base only in HF space)", info="whisper model selection") + model_selection = gr.Dropdown(choices=avaliable_models, value="base", label="whisper model (base only in HF space)", info="whisper model selection", interactive=False) with gr.Column(scale=4): just_transcribe_button = gr.Button("Just Transcribe", variant="primary") - bleep_transcribe_button = gr.Button("Transcribe & Bleep", variant="primary") + transcribe_and_bleep_button = gr.Button("Transcribe & Bleep", variant="primary") with tempfile.TemporaryDirectory() as tmpdirname: with gr.Row(): @@ -70,16 +70,18 @@ height="50vw", ) - @just_transcribe_button.click(inputs=[url_input], outputs=[og_video, transcript_output]) - def just_transcribe(url_input): + @just_transcribe_button.click(inputs=[url_input, model_selection], outputs=[og_video, bleep_video, transcript_output]) + def just_transcribe(url_input, model_selection): temporary_video_location = tmpdirname + "/original_" + str(uuid.uuid4()) + ".mp4" + temporary_audio_location = temporary_video_location.replace("mp4", "mp3") + download_video(url_input, temporary_video_location) filename = open(temporary_video_location, "rb") byte_file = io.BytesIO(filename.read()) with open(temporary_video_location, "wb") as out: out.write(byte_file.read()) - new_video = gr.Video( + new_og_video = gr.Video( value=temporary_video_location, visible=True, show_download_button=True, @@ -89,10 +91,80 @@ def just_transcribe(url_input): width="50vw", height="50vw", ) - - transcript_output = "" - return new_video, transcript_output + new_bleep_video = gr.Video( + visible=False, + show_download_button=True, + show_label=True, + label="bleeped video", + format="mp4", + width="50vw", + height="50vw", + ) + + + extract_audio(temporary_video_location, temporary_audio_location) + transcript, timestamped_transcript = transcribe(local_file_path=temporary_audio_location, model=model_selection) + + return new_og_video, new_bleep_video, transcript + + + @transcribe_and_bleep_button.click(inputs=[url_input, model_selection, bleep_words], outputs=[og_video, bleep_video, transcript_output]) + def transcribe_and_bleep(url_input, model_selection, bleep_words): + if len(bleep_words) > 0: + temporary_video_location = tmpdirname + "/original_" + str(uuid.uuid4()) + ".mp4" + temporary_audio_location = temporary_video_location.replace("mp4", "mp3") + + download_video(url_input, temporary_video_location) + filename = open(temporary_video_location, "rb") + byte_file = io.BytesIO(filename.read()) + with open(temporary_video_location, "wb") as out: + out.write(byte_file.read()) + + new_og_video = gr.Video( + value=temporary_video_location, + visible=True, + show_download_button=True, + show_label=True, + label="original video", + format="mp4", + width="50vw", + height="50vw", + ) + + extract_audio(temporary_video_location, temporary_audio_location) + transcript, timestamped_transcript = transcribe(local_file_path=temporary_audio_location, model=model_selection) + + bleep_word_list = bleep_words.split(",") + bleep_word_list = [v.strip() for v in bleep_word_list if len(v.strip()) > 0] + bleep_video_output = temporary_video_location.replace("original", "bleep") + bleep_audio_output = bleep_video_output.replace("mp4", "mp3") + + bleep_replace( + temporary_video_location, + temporary_audio_location, + bleep_video_output, + bleep_audio_output, + bleep_word_list, + timestamped_transcript, + ) + + new_bleep_video = gr.Video( + value=bleep_video_output, + visible=True, + show_download_button=True, + show_label=True, + label="bleeped video", + format="mp4", + width="50vw", + height="50vw", + ) + + return new_og_video, new_bleep_video, transcript + else: + gr.Warning("bleep words empty!", duration=3) + return None, None, None + with gr.TabItem("💡 About"): with gr.Blocks() as about: gr.Markdown( From c80961a7a821027b1f175126bb7d0bc80e773a99 Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 16:02:05 -0700 Subject: [PATCH 6/9] readme update --- README.md | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5bdd9ea..239a793 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ HuggingFace Space -Open In Colab Youtube [![Python application](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/badge.svg)](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/python-app.yml) +Open In Colab Youtube +[![Python application](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/badge.svg)](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/python-app.yml) Bleep That Sh*t! - A whisper app that bleeps out chosen words in YouTube videos | Product Hunt # bleep that sh*t @@ -36,13 +37,6 @@ pip install -r requirements.txt You will need [ffmpeg](https://www.ffmpeg.org/download.html) installed on your machine as well. -## Instructions for bleeping your own **local** videos - -Start this streamlit demo locally that lets you drag and drop local video files to bleep - -```python -python -m streamlit run bleep_that_sht/app_video_upload.py -``` ## Instructions for bleeping **youtube** videos via youtube / shorts url @@ -52,4 +46,20 @@ Start this streamlit demo locally that lets you enter in a youtube / shorts url python -m streamlit run bleep_that_sht/app_url_download.py ``` +Alternatively you can start a gradio server with the same functionality + +```python +python -m bleep_that_sht/gradio_app_url_download.py +``` + This is the version hosted in the HF space [![HuggingFace Space](https://img.shields.io/badge/🤗-HuggingFace%20Space-cyan.svg)](https://huggingface.co/spaces/neonwatty/bleep_that_sht). + + + +## Instructions for bleeping your own **local** videos + +Start this streamlit demo locally that lets you drag and drop local video files to bleep + +```python +python -m streamlit run bleep_that_sht/app_video_upload.py +``` \ No newline at end of file From bf3778771c17f168f6908c2c4883a995cbe01518 Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 19:44:24 -0700 Subject: [PATCH 7/9] readme update --- README.md | 8 +++++++- requirements.gradio | 4 ++++ requirements.txt => requirements.streamlit | 0 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 requirements.gradio rename requirements.txt => requirements.streamlit (100%) diff --git a/README.md b/README.md index 239a793..3017c27 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,13 @@ https://github.com/neonwatty/bleep_that_sht/assets/16326421/63ebd7a0-46f6-4efd-8 To get setup to run the notebook / bleep your own videos / run the strealit demo first install the requirements for this project by pasting the below in your terminal. ```python -pip install -r requirements.txt +pip install -r requirements.streamlit +``` + +To install requirements for the gradio demo use this install + +```python +pip install -r requirements.gradio ``` You will need [ffmpeg](https://www.ffmpeg.org/download.html) installed on your machine as well. diff --git a/requirements.gradio b/requirements.gradio new file mode 100644 index 0000000..e04eb08 --- /dev/null +++ b/requirements.gradio @@ -0,0 +1,4 @@ +whisper-timestamped +moviepy +yt-dlp +gradio diff --git a/requirements.txt b/requirements.streamlit similarity index 100% rename from requirements.txt rename to requirements.streamlit From 3c7c2872709f7fd6513ec5d3f1b7f65c4c74d785 Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Tue, 16 Jul 2024 19:46:46 -0700 Subject: [PATCH 8/9] readme update --- requirements.streamlit | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.streamlit b/requirements.streamlit index f3abd7b..79cb2e8 100644 --- a/requirements.streamlit +++ b/requirements.streamlit @@ -1,5 +1,4 @@ whisper-timestamped moviepy -pydub -git+https://github.com/neonwatty/pytube.git +yt-dlp streamlit From a1b27206ce279aece87cc2f1c86eda4c8cffb3cc Mon Sep 17 00:00:00 2001 From: Jeremy Watt Date: Wed, 17 Jul 2024 07:42:22 -0700 Subject: [PATCH 9/9] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3017c27..eecb77f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ HuggingFace Space Open In Colab Youtube -[![Python application](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/badge.svg)](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/python-app.yml) Bleep That Sh*t! - A whisper app that bleeps out chosen words in YouTube videos | Product Hunt +[![Python application](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/badge.svg)](https://github.com/neonwatty/bleep_that_sht/actions/workflows/python-app.yml/python-app.yml) Bleep That Sh*t! - A whisper app that bleeps out chosen words in YouTube videos | Product Hunt # bleep that sh*t @@ -68,4 +68,4 @@ Start this streamlit demo locally that lets you drag and drop local video files ```python python -m streamlit run bleep_that_sht/app_video_upload.py -``` \ No newline at end of file +```