Spaces:
Running
Running
cached response
Browse files
app.py
CHANGED
@@ -75,7 +75,8 @@ def process_youtube_link(youtube_link):
|
|
75 |
audio_name = audio_stream.default_filename
|
76 |
st.write(f"Downloaded {audio_name}")
|
77 |
except pytube.exceptions.AgeRestrictedError:
|
78 |
-
st.
|
|
|
79 |
|
80 |
try:
|
81 |
os.remove('sample.mp4')
|
@@ -157,7 +158,7 @@ with st.sidebar:
|
|
157 |
container_transcript_chat = st.container()
|
158 |
|
159 |
# Source Selection
|
160 |
-
option = st.radio("Select source:", [ "Use YouTube link","Example"], index=0)
|
161 |
|
162 |
# Upload audio file
|
163 |
if option == "Upload an audio file":
|
@@ -204,7 +205,7 @@ elif option == "Use YouTube link":
|
|
204 |
# audio = audio.set_frame_rate(sample_rate)
|
205 |
# except Exception as e:
|
206 |
# st.write(f"Error: {str(e)}")
|
207 |
-
elif option == 'Example':
|
208 |
youtube_link = 'https://www.youtube.com/watch?v=TamrOZX9bu8'
|
209 |
audio_name = 'Stephen A. Smith has JOKES with Shannon Sharpe'
|
210 |
st.write(f'Loaded audio file from {youtube_link} - {audio_name} ππ')
|
@@ -361,19 +362,19 @@ if "audio" in locals():
|
|
361 |
transcript_string = '\n'.join([f"{s['speaker']} start={s['start']:.1f}s end={s['end']:.1f}s : {s['transcript']}" for s in transcript_json])
|
362 |
|
363 |
@st.cache_data
|
364 |
-
def get_initial_response(
|
|
|
365 |
initial_response = openai.ChatCompletion.create(
|
366 |
model=st.session_state["openai_model"],
|
367 |
-
messages=messages
|
368 |
)
|
369 |
return initial_response['choices'][0]['message']['content']
|
370 |
|
371 |
# Chat container
|
372 |
with container_transcript_chat:
|
373 |
# get a summary of transcript from ChatGpt
|
374 |
-
st.session_state.messages[1]['content'] = st.session_state.messages[1]['content'].format(transcript_string)
|
375 |
try:
|
376 |
-
init = get_initial_response(
|
377 |
except openai.error.APIError:
|
378 |
# st.stop('It is not you. It is not this app. It is OpenAI API thats having issues.')
|
379 |
init = ''
|
|
|
75 |
audio_name = audio_stream.default_filename
|
76 |
st.write(f"Downloaded {audio_name}")
|
77 |
except pytube.exceptions.AgeRestrictedError:
|
78 |
+
st.warning('Age restricted videos cannot be processed.')
|
79 |
+
st.stop()
|
80 |
|
81 |
try:
|
82 |
os.remove('sample.mp4')
|
|
|
158 |
container_transcript_chat = st.container()
|
159 |
|
160 |
# Source Selection
|
161 |
+
option = st.radio("Select source:", [ "Use YouTube link","See Example"], index=0)
|
162 |
|
163 |
# Upload audio file
|
164 |
if option == "Upload an audio file":
|
|
|
205 |
# audio = audio.set_frame_rate(sample_rate)
|
206 |
# except Exception as e:
|
207 |
# st.write(f"Error: {str(e)}")
|
208 |
+
elif option == 'See Example':
|
209 |
youtube_link = 'https://www.youtube.com/watch?v=TamrOZX9bu8'
|
210 |
audio_name = 'Stephen A. Smith has JOKES with Shannon Sharpe'
|
211 |
st.write(f'Loaded audio file from {youtube_link} - {audio_name} ππ')
|
|
|
362 |
transcript_string = '\n'.join([f"{s['speaker']} start={s['start']:.1f}s end={s['end']:.1f}s : {s['transcript']}" for s in transcript_json])
|
363 |
|
364 |
@st.cache_data
|
365 |
+
def get_initial_response(transcript_string):
|
366 |
+
st.session_state.messages[1]['content'] = st.session_state.messages[1]['content'].format(transcript_string)
|
367 |
initial_response = openai.ChatCompletion.create(
|
368 |
model=st.session_state["openai_model"],
|
369 |
+
messages=st.session_state.messages
|
370 |
)
|
371 |
return initial_response['choices'][0]['message']['content']
|
372 |
|
373 |
# Chat container
|
374 |
with container_transcript_chat:
|
375 |
# get a summary of transcript from ChatGpt
|
|
|
376 |
try:
|
377 |
+
init = get_initial_response(transcript_string)
|
378 |
except openai.error.APIError:
|
379 |
# st.stop('It is not you. It is not this app. It is OpenAI API thats having issues.')
|
380 |
init = ''
|