Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,7 +14,8 @@ from dotenv import load_dotenv
|
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 17 |
-
google_genai.configure(api_key=
|
|
|
|
| 18 |
|
| 19 |
st.set_page_config(
|
| 20 |
page_title="VidText"
|
|
@@ -76,59 +77,71 @@ youtube_url_tab, file_select_tab, audio_file_tab = st.tabs(["Youtube URL","Video
|
|
| 76 |
|
| 77 |
with youtube_url_tab:
|
| 78 |
url = st.text_input("Enter the Youtube url")
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
yt_video, title = youtube_video_downloader(url)
|
| 82 |
-
if url:
|
| 83 |
-
if st.button("Transcribe", key="yturl"):
|
| 84 |
-
with st.spinner("Transcribing..."):
|
| 85 |
-
audio = audio_extraction(yt_video)
|
| 86 |
-
ytvideo_transcript = transcriber_pass(audio)
|
| 87 |
-
st.success(f"Transcription successful")
|
| 88 |
-
st.write(ytvideo_transcript)
|
| 89 |
-
# st.write(f'Completed in {run_time}')
|
| 90 |
-
|
| 91 |
-
if st.button("Generate Summary"):
|
| 92 |
-
summary = generate_ai_summary(ytvideo_transcript)
|
| 93 |
-
st.write(summary)
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
# Video file transcription
|
| 97 |
|
| 98 |
with file_select_tab:
|
| 99 |
uploaded_video_file = st.file_uploader("Upload video file", type="mp4")
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
-
if st.button("Transcribe", key="vidfile"):
|
| 106 |
-
with st.spinner("Transcribing..."):
|
| 107 |
-
audio = audio_extraction(uploaded_video_file)
|
| 108 |
-
# audio = audio_processing(audio)
|
| 109 |
-
video_transcript = transcriber_pass(audio)
|
| 110 |
-
st.success(f"Transcription successful")
|
| 111 |
-
st.write(video_transcript)
|
| 112 |
-
|
| 113 |
-
if st.button("Generate Summary", key="ti2"):
|
| 114 |
-
summary = generate_ai_summary(video_transcript)
|
| 115 |
-
st.write(summary)
|
| 116 |
-
|
| 117 |
-
|
| 118 |
|
| 119 |
# Audio transcription
|
| 120 |
with audio_file_tab:
|
| 121 |
audio_file = st.file_uploader("Upload audio file", type="mp3")
|
| 122 |
|
| 123 |
-
|
| 124 |
-
if
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
|
| 17 |
+
google_genai.configure(api_key=
|
| 18 |
+
GOOGLE_API_KEY)
|
| 19 |
|
| 20 |
st.set_page_config(
|
| 21 |
page_title="VidText"
|
|
|
|
| 77 |
|
| 78 |
with youtube_url_tab:
|
| 79 |
url = st.text_input("Enter the Youtube url")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
+
try:
|
| 82 |
+
|
| 83 |
+
yt_video, title = youtube_video_downloader(url)
|
| 84 |
+
if url:
|
| 85 |
+
if st.button("Transcribe", key="yturl"):
|
| 86 |
+
with st.spinner("Transcribing..."):
|
| 87 |
+
audio = audio_extraction(yt_video)
|
| 88 |
+
ytvideo_transcript = transcriber_pass(audio)
|
| 89 |
+
st.success(f"Transcription successful")
|
| 90 |
+
st.write(f'Video title: {title}')
|
| 91 |
+
st.write('___')
|
| 92 |
+
st.write(ytvideo_transcript)
|
| 93 |
+
# st.write(f'Completed in {run_time}')
|
| 94 |
+
|
| 95 |
+
if st.button("Generate Summary"):
|
| 96 |
+
summary = generate_ai_summary(ytvideo_transcript)
|
| 97 |
+
st.write(summary)
|
| 98 |
+
except Exception as e:
|
| 99 |
+
st.error(e)
|
| 100 |
|
| 101 |
# Video file transcription
|
| 102 |
|
| 103 |
with file_select_tab:
|
| 104 |
uploaded_video_file = st.file_uploader("Upload video file", type="mp4")
|
| 105 |
|
| 106 |
+
try:
|
| 107 |
+
if uploaded_video_file:
|
| 108 |
+
video_file = uploaded_video_file
|
| 109 |
+
|
| 110 |
+
if st.button("Transcribe", key="vidfile"):
|
| 111 |
+
with st.spinner("Transcribing..."):
|
| 112 |
+
with st.spinner('Extracting audio...')
|
| 113 |
+
audio = audio_extraction(uploaded_video_file)
|
| 114 |
+
|
| 115 |
+
video_transcript = transcriber_pass(audio)
|
| 116 |
+
st.success(f"Transcription successful")
|
| 117 |
+
st.write(video_transcript)
|
| 118 |
+
|
| 119 |
+
if st.button("Generate Summary", key="ti2"):
|
| 120 |
+
summary = generate_ai_summary(video_transcript)
|
| 121 |
+
st.write(summary)
|
| 122 |
+
|
| 123 |
+
except Exception as e:
|
| 124 |
+
st.error(e)
|
| 125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
# Audio transcription
|
| 128 |
with audio_file_tab:
|
| 129 |
audio_file = st.file_uploader("Upload audio file", type="mp3")
|
| 130 |
|
| 131 |
+
try:
|
| 132 |
+
if audio_file:
|
| 133 |
+
if st.button("Transcribe", key="audiofile"):
|
| 134 |
+
with st.spinner("Transcribing..."):
|
| 135 |
+
processed_audio = audio_processing(audio_file)
|
| 136 |
+
audio_transcript = transcriber_pass(processed_audio)
|
| 137 |
+
st.success(f"Transcription successful")
|
| 138 |
+
st.write(audio_transcript)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
if st.button("Generate Summary", key="ti1"):
|
| 142 |
+
summary = generate_ai_summary(audio_transcript)
|
| 143 |
+
st.write(summary)
|
| 144 |
|
| 145 |
+
except Exception as e:
|
| 146 |
+
st.error(e)
|
| 147 |
+
|