Jaward commited on
Commit
90088b0
·
verified ·
1 Parent(s): c56b786

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -35,6 +35,7 @@ import copy
35
  from pathlib import Path
36
 
37
  gr.set_static_paths(paths=[Path.cwd().absolute()/"outputs"])
 
38
  def get_instructor_name(speaker):
39
  instructor_names = {
40
  "feynman.mp3": "Professor Richard Feynman",
@@ -411,6 +412,7 @@ def get_gradio_file_url(local_path):
411
  if not local_path:
412
  return None
413
  relative_path = os.path.relpath(local_path, os.getcwd())
 
414
  return f"/gradio_api/file={relative_path}"
415
 
416
  # Async generate lecture materials and audio
@@ -826,7 +828,7 @@ Example: 'Received {total_slides} slides, {total_slides} scripts, and HTML files
826
  audio_urls = [None] * len(scripts)
827
  audio_timeline = ""
828
  for i in range(len(scripts)):
829
- audio_timeline += f'<audio id="audio-{i+1}" controls src="" style="display: inline-block; margin: 0 10px; width: 200px;"><span>Loading...</span></audio>'
830
 
831
  file_paths = [f for f in os.listdir(OUTPUT_DIR) if f.endswith(('.md', '.txt'))]
832
  file_paths.sort()
@@ -926,9 +928,9 @@ Example: 'Received {total_slides} slides, {total_slides} scripts, and HTML files
926
  audio_timeline = ""
927
  for j, url in enumerate(audio_urls):
928
  if url:
929
- audio_timeline += f'<audio id="audio-{j+1}" controls src="{url}" style="display: inline-block; margin: 0 10px; width: 200px;"></audio>'
930
  else:
931
- audio_timeline += f'<audio id="audio-{j+1}" controls src="" style="display: inline-block; margin: 0 10px; width: 200px;"><span>Audio unavailable</span></audio>'
932
 
933
  slides_info = json.dumps({"htmlFiles": html_file_urls, "audioFiles": audio_urls})
934
  html_output = f"""
 
35
  from pathlib import Path
36
 
37
  gr.set_static_paths(paths=[Path.cwd().absolute()/"outputs"])
38
+
39
  def get_instructor_name(speaker):
40
  instructor_names = {
41
  "feynman.mp3": "Professor Richard Feynman",
 
412
  if not local_path:
413
  return None
414
  relative_path = os.path.relpath(local_path, os.getcwd())
415
+ print(f"Relative path: {relative_path}")
416
  return f"/gradio_api/file={relative_path}"
417
 
418
  # Async generate lecture materials and audio
 
828
  audio_urls = [None] * len(scripts)
829
  audio_timeline = ""
830
  for i in range(len(scripts)):
831
+ audio_timeline += f'<audio id="audio-{i+1}" controls type="audio/mpeg" src="" style="display: inline-block; margin: 0 10px; width: 200px;"><span>Loading...</span></audio>'
832
 
833
  file_paths = [f for f in os.listdir(OUTPUT_DIR) if f.endswith(('.md', '.txt'))]
834
  file_paths.sort()
 
928
  audio_timeline = ""
929
  for j, url in enumerate(audio_urls):
930
  if url:
931
+ audio_timeline += f'<audio id="audio-{j+1}" controls type="audio/mpeg" src="{url}" style="display: inline-block; margin: 0 10px; width: 200px;"></audio>'
932
  else:
933
+ audio_timeline += f'<audio id="audio-{j+1}" controls type="audio/mpeg" src="" style="display: inline-block; margin: 0 10px; width: 200px;"><span>Audio unavailable</span></audio>'
934
 
935
  slides_info = json.dumps({"htmlFiles": html_file_urls, "audioFiles": audio_urls})
936
  html_output = f"""