Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ Run the following to view all available options:

yt_whisper --help


## Similar Work
A streamlit based webapp using yt-whisper for capturing and downloading subtitles from youtube videos as per the user's input : https://github.com/prateekralhan/Youtube-Whisper-Streamlit

![](https://user-images.githubusercontent.com/29462447/201472171-0c20444c-82a4-444e-85eb-a1898c9ae896.gif)


## License

This script is open-source and licensed under the MIT License. For more details, check the [LICENSE](LICENSE) file.
1 change: 1 addition & 0 deletions streamlit_app/Aptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ffmpeg
20 changes: 20 additions & 0 deletions streamlit_app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.7

RUN pip install virtualenv
ENV VIRTUAL_ENV=/venv
RUN virtualenv venv -p python3
ENV PATH="VIRTUAL_ENV/bin:$PATH"

WORKDIR /app
ADD . /app

# Install dependencies
RUN pip install -r requirements.txt
RUN apt-get update
RUN apt-get install ffmpeg

# Expose port
ENV PORT 8501

# Run the application:
CMD ["streamlit","run","app.py"]
1 change: 1 addition & 0 deletions streamlit_app/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: sh setup.sh && streamlit run app.py
74 changes: 74 additions & 0 deletions streamlit_app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import os
import subprocess
import glob
import shutil
import streamlit as st
from PIL import Image
from whisper.tokenizer import LANGUAGES

@st.cache(persist=True,allow_output_mutation=False,show_spinner=True,suppress_st_warning=True)
def clean_directory(dirpath):
for filename in os.listdir(dirpath):
filepath = os.path.abspath(os.path.join(dirpath, filename))
try:
shutil.rmtree(filepath)
except OSError:
os.remove(filepath)

st.set_page_config(
page_title="Youtube - Whisper",
page_icon="🎶",
layout="centered",
initial_sidebar_state="auto",
)

main_image = Image.open('static/main_banner.png')

download_path = "output/"
clean_directory(download_path)

st.image(main_image,use_column_width='auto')
st.title("✨ Automatic YouTube subtitle generation 🔊")
st.error(" 🔴 THIS IS MEANT TO BE USED FOR EDUCATIONAL PURPOSES ONLY!! 🔴")
st.info('⚠ Fetching the YouTube video and it\'s subtitles generation may take several minutes depending on the time duration, size and your choices 😉')

col1, col2, col3, col4 = st.columns(4)
with col1:
model_type = st.radio("Please choose your model type", ('Tiny', 'Base', 'Small', 'Medium', 'Large'))
with col2:
format_type = st.radio("Please choose your output format type", ('VTT', 'SRT'))
with col3:
task_type = st.radio("Please choose your task type", ('Transcribe', 'Translate'))
with col4:
language = st.selectbox('Please select the language',tuple(LANGUAGES.values()))

url = st.text_input("Enter your YouTube Video URL: 🔗")
if url is not None or url != '':
if st.button("Fetch Video and Generate Subtitles 🚀"):
st.video(url.strip())
with st.spinner("Working... 💫 Meanwhile please enjoy your video 😉"):
subprocess.run(["yt_whisper", url, "--model", model_type.lower(), "--format", format_type.lower(), "--output_dir", "output", "--verbose", "True", "--task", task_type.lower(), "--language", language.title()])

filename = glob.glob("output/*")[0]
output_file = open(filename,"r")
output_file_data = output_file.read()

if filename.endswith(".srt"):
mime_type = "text/plain"
else:
mime_type = "text/vtt"

if st.download_button(
label="Download Subtitles 📝",
data=output_file_data,
file_name=filename,
mime=mime_type
):
st.balloons()
st.success('✅ Download Successful !!')

else:
st.warning('⚠ Please enter the URL! 😯')


st.markdown("<br><hr><center>Made with ❤️ by <a href='mailto:ralhanprateek@gmail.com?subject=YT - Whisper WebApp!&body=Please specify the issue you are facing with the app.'><strong>Prateek Ralhan</strong></a> with the help of [yt-whisper](https://github.com/m1guelpf/yt-whisper) built by [m1guelpf](https://github.com/m1guelpf) ✨</center><hr>", unsafe_allow_html=True)
Binary file added streamlit_app/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
WEBVTT

00:00.000 --> 00:20.520
Youth

00:20.520 --> 00:26.520
You know the rules and so do I

00:26.520 --> 00:30.520
I've broken it means far I'm deep in love

00:30.520 --> 00:34.520
You won't get this wrong any other guy

00:34.520 --> 00:39.520
I just wanna tell you how I'm feeling

00:39.520 --> 00:42.520
Gotta make you understand

00:42.520 --> 00:44.520
Never gonna give you home

00:44.520 --> 00:46.520
Never gonna let you down

00:46.520 --> 00:50.520
Never gonna run around and you just do

00:50.520 --> 00:53.520
Never gonna make you cry

00:53.520 --> 00:55.520
Never gonna shake you back

00:55.520 --> 00:57.520
Never gonna jay on the mind

00:57.520 --> 00:59.520
And hurt you

00:59.520 --> 01:04.520
We know each other for so long

01:04.520 --> 01:06.520
You'll start to be naked now

01:06.520 --> 01:08.520
You'll just start to say

01:08.520 --> 01:10.520
If you stop being focused

01:10.520 --> 01:12.520
We'll go alone

01:12.520 --> 01:15.520
We know the game I'm wearing

01:15.520 --> 01:21.520
Gotta play it and you do I speak how I'm feeling

01:21.520 --> 01:23.520
Don't tell me or two

01:23.520 --> 01:24.520
But you see

01:24.520 --> 01:26.520
Never gonna give you home

01:26.520 --> 01:28.520
Never gonna let you down

01:28.520 --> 01:32.520
Never gonna run around and you just do

01:32.520 --> 01:35.520
Never gonna make you cry

01:35.520 --> 01:37.520
Never gonna shake you back

01:37.520 --> 01:39.520
Never gonna jay on the mind

01:39.520 --> 01:41.520
And hurt you

01:41.520 --> 01:43.520
Never gonna give you home

01:43.520 --> 01:46.520
Never gonna let you down

01:46.520 --> 01:50.520
Never gonna run around and you just do

01:50.520 --> 01:52.520
Never gonna make you cry

01:52.520 --> 01:54.520
Never gonna shake you back

01:54.520 --> 01:56.520
Never gonna jay on the mind

01:56.520 --> 01:59.520
And hurt you

01:59.520 --> 02:02.520
Never gonna give you home

02:02.520 --> 02:07.520
Never gonna give you home

02:07.520 --> 02:12.520
Never gonna give you home

02:12.520 --> 02:14.520
Never gonna give me, never gonna give me

02:14.520 --> 02:16.520
In my life

02:16.520 --> 02:20.520
We've known each other for so long

02:20.520 --> 02:22.520
Your husband ain't king of

02:22.520 --> 02:24.520
Your just has to say

02:24.520 --> 02:26.520
It's a surprise for the husband

02:26.520 --> 02:28.520
Go on, on

02:28.520 --> 02:32.520
We know the game and we're gonna play it

02:32.520 --> 02:37.520
I just wanna tell you how I feel it

02:37.520 --> 02:40.520
Gotta make you understand

02:40.520 --> 02:42.520
Never gonna give you, or

02:42.520 --> 02:44.520
We've known each other for so long

02:44.520 --> 02:46.520
Your husband ain't king of

02:46.520 --> 02:48.520
Your just has to say

02:48.520 --> 02:50.520
It's a surprise for the husband

02:50.520 --> 02:53.520
Go on, on we're gonna save the

02:53.520 --> 02:56.520
Bad, no, no, no, no

02:56.520 --> 02:58.520
And bad too

02:58.520 --> 03:00.520
Never gonna give you, or

03:00.520 --> 03:02.520
We've known each other for so long

03:02.520 --> 03:04.520
We've known each other for so long

03:04.520 --> 03:06.520
We've known each other for so long

03:06.520 --> 03:10.520
Your husband ain't king of

03:10.520 --> 03:12.520
Your just has to say

03:12.520 --> 03:14.520
It's a surprise for the husband

03:14.520 --> 03:16.520
Go on, on we're gonna give you, or

03:16.520 --> 03:20.520
We've known each other for so long

03:20.520 --> 03:22.520
Your husband ain't king of

03:22.520 --> 03:26.520
Your just has to say

Binary file added streamlit_app/requirements.txt
Binary file not shown.
1 change: 1 addition & 0 deletions streamlit_app/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.7.13
9 changes: 9 additions & 0 deletions streamlit_app/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mkdir -p ~/.streamlit/
echo "[general]
email = \"ralhanprateek@gmail.com\"
" > ~/.streamlit/credentials.toml
echo "[server]
headless = true
port = $PORT
enableCORS = false
" > ~/.streamlit/config.toml
Binary file added streamlit_app/static/main_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.