vpavlenko commited on
Commit
d14d2b9
·
1 Parent(s): f05c3e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -5,6 +5,8 @@ import allin1
5
 
6
  from pathlib import Path
7
 
 
 
8
  HEADER = """
9
  <header style="text-align: center;">
10
  <h1>
@@ -47,13 +49,14 @@ HEADER = """
47
 
48
  CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
49
 
50
- def compress_files(folder_path):
51
  """Compresses files in the specified folder into a .tar.gz"""
52
  tar_path = folder_path + ".tar.gz"
53
  with tarfile.open(tar_path, "w:gz") as tar:
54
  for root, _, files in os.walk(folder_path):
55
  for file in files:
56
  tar.add(os.path.join(root, file), arcname=file)
 
57
  return tar_path
58
 
59
  def analyze(path):
@@ -70,7 +73,8 @@ def analyze(path):
70
  allin1.sonify(result, out_dir='./sonif')
71
  sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
72
 
73
- compressed_file = compress_files(f"demix/htdemucs/{path.stem}")
 
74
 
75
  return result.bpm, fig, sonif_path, compressed_file
76
 
@@ -113,7 +117,7 @@ with gr.Blocks() as demo:
113
  button.click(
114
  fn=analyze,
115
  inputs=input_audio_path,
116
- outputs=[output_bpm, output_viz, output_sonif],
117
  api_name='analyze',
118
  )
119
 
 
5
 
6
  from pathlib import Path
7
 
8
+ from dissector import generate_dissector_data
9
+
10
  HEADER = """
11
  <header style="text-align: center;">
12
  <h1>
 
49
 
50
  CACHE_EXAMPLES = os.getenv('CACHE_EXAMPLES', '1') == '1'
51
 
52
+ def compress_files(folder_path, dissector_file):
53
  """Compresses files in the specified folder into a .tar.gz"""
54
  tar_path = folder_path + ".tar.gz"
55
  with tarfile.open(tar_path, "w:gz") as tar:
56
  for root, _, files in os.walk(folder_path):
57
  for file in files:
58
  tar.add(os.path.join(root, file), arcname=file)
59
+ tar.add(dissector_file)
60
  return tar_path
61
 
62
  def analyze(path):
 
73
  allin1.sonify(result, out_dir='./sonif')
74
  sonif_path = Path(f'./sonif/{path.stem}.sonif{path.suffix}').resolve().as_posix()
75
 
76
+ dissector_file = generate_dissector_data(path.stem, result)
77
+ compressed_file = compress_files(f"demix/htdemucs/{path.stem}", dissector_file)
78
 
79
  return result.bpm, fig, sonif_path, compressed_file
80
 
 
117
  button.click(
118
  fn=analyze,
119
  inputs=input_audio_path,
120
+ outputs=[output_bpm, output_viz, output_sonif, output_compressed],
121
  api_name='analyze',
122
  )
123