Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,7 @@ def convert_to_audio(video_filename):
|
|
59 |
|
60 |
|
61 |
@st.cache_data
|
62 |
-
def
|
63 |
if openai.api_key is None:
|
64 |
return "No OpenAI API Key provided."
|
65 |
messages = [{"role": "user", "content": prompt}]
|
@@ -122,10 +122,9 @@ def main():
|
|
122 |
- Fetch transcript from YouTube API (if available) by clicking the **Fetch Transcript** button.
|
123 |
- Transcribe the video using the Whisper model by clicking the **Transcribe (Whisper)** button.
|
124 |
- The transcript will be displayed in a text area below.
|
125 |
-
- You can download the video audio or transcript by clicking the respective buttons.
|
126 |
- If you have an OpenAI API Key, you will be able to generate a summary of the transcript by ChatGPT.
|
127 |
- The summary will be displayed in a text area below.
|
128 |
-
- You can download the summary by clicking the
|
129 |
"""
|
130 |
)
|
131 |
|
@@ -214,20 +213,20 @@ def process_youtube_video(video_id, col, emp, text_filename):
|
|
214 |
transcript_text = "\n".join(
|
215 |
[re.sub("\s+", " ", chunk["text"]) for chunk in transcript_text]
|
216 |
)
|
217 |
-
c1, c2 = st.columns(
|
218 |
with c1:
|
219 |
modified_text = st.text_area(
|
220 |
"Transcript", transcript_text, height=500
|
221 |
)
|
222 |
-
st.download_button("Download", modified_text, text_filename)
|
223 |
with c2:
|
224 |
-
openai_summarization =
|
225 |
PROMPT.format(modified_text)
|
226 |
)
|
227 |
summarized_text = st.text_area(
|
228 |
"Summarized Transcript", openai_summarization, height=500
|
229 |
)
|
230 |
-
st.download_button("Download", summarized_text, text_filename)
|
231 |
|
232 |
except CouldNotRetrieveTranscript:
|
233 |
emp.warning("Could Not Retrieve API Transcripts for this video.")
|
|
|
59 |
|
60 |
|
61 |
@st.cache_data
|
62 |
+
def summarise(prompt, model="gpt-3.5-turbo"):
|
63 |
if openai.api_key is None:
|
64 |
return "No OpenAI API Key provided."
|
65 |
messages = [{"role": "user", "content": prompt}]
|
|
|
122 |
- Fetch transcript from YouTube API (if available) by clicking the **Fetch Transcript** button.
|
123 |
- Transcribe the video using the Whisper model by clicking the **Transcribe (Whisper)** button.
|
124 |
- The transcript will be displayed in a text area below.
|
|
|
125 |
- If you have an OpenAI API Key, you will be able to generate a summary of the transcript by ChatGPT.
|
126 |
- The summary will be displayed in a text area below.
|
127 |
+
- You can download the video, audio, transcript or summary by clicking the respective download buttons.
|
128 |
"""
|
129 |
)
|
130 |
|
|
|
213 |
transcript_text = "\n".join(
|
214 |
[re.sub("\s+", " ", chunk["text"]) for chunk in transcript_text]
|
215 |
)
|
216 |
+
c1, c2 = st.columns(2)
|
217 |
with c1:
|
218 |
modified_text = st.text_area(
|
219 |
"Transcript", transcript_text, height=500
|
220 |
)
|
221 |
+
st.download_button("Download Transcript", modified_text, text_filename)
|
222 |
with c2:
|
223 |
+
openai_summarization = summarise(
|
224 |
PROMPT.format(modified_text)
|
225 |
)
|
226 |
summarized_text = st.text_area(
|
227 |
"Summarized Transcript", openai_summarization, height=500
|
228 |
)
|
229 |
+
st.download_button("Download Summary", summarized_text, text_filename)
|
230 |
|
231 |
except CouldNotRetrieveTranscript:
|
232 |
emp.warning("Could Not Retrieve API Transcripts for this video.")
|