ziqiangao commited on
Commit
bc54299
·
1 Parent(s): 760d99b

fix error and add fonts

Browse files
Lexend-Black.ttf ADDED
Binary file (78.5 kB). View file
 
Lexend-Bold.ttf ADDED
Binary file (78.6 kB). View file
 
Lexend-VariableFont_wght.ttf ADDED
Binary file (176 kB). View file
 
SpaceMono-Bold.ttf ADDED
Binary file (86.6 kB). View file
 
app.py CHANGED
@@ -14,7 +14,7 @@ import ffmpeg
14
  import subprocess
15
  import traceback
16
 
17
- path = '/app/' # Update with your path
18
 
19
  def getRenderCords(ta: list, idx: int, res: int = 1024, size: tuple = (1280, 720)) -> list:
20
  i = idx - res // 2
@@ -180,25 +180,24 @@ def main(file, name, fps=30, res: tuple=(1280,720), oscres = 512):
180
  ]
181
  subprocess.run(ffmpeg_cmd)
182
 
183
- def gradio_interface(audio_file, output_name, fps=30, resolution='1280x720', oscres=512):
184
- try:
185
  res = tuple(map(int, resolution.split('x')))
186
  main(audio_file, output_name, fps=fps, res=res, oscres=oscres)
187
  return f"Output video '{output_name}.mp4' has been created. Click the link to download."
188
- except Exception as e:
189
- return f"Error processing file: {e}"
190
 
191
  # Define Gradio interface
192
  iface = gr.Interface(
193
  fn=gradio_interface,
194
  inputs=[
195
- gr.inputs.File(label="Upload your MP3 file"),
196
- gr.inputs.Textbox(label="Output Video Name (without extension)"),
197
- gr.inputs.Number(label="Frames per Second", default=30, min=1, max=60),
198
- gr.inputs.Textbox(label="Output Resolution (e.g., 1280x720)", default="1280x720"),
199
- gr.inputs.Number(label="Number of Visualization Segments", default=512)
 
200
  ],
201
- outputs=gr.outputs.Textbox(label="Output"),
202
  title="MP3 to Video Visualization",
203
  description="Upload an MP3 file and configure parameters to create a visualization video."
204
  )
 
14
  import subprocess
15
  import traceback
16
 
17
+ path = 'C:/Users/ziqia/Downloads/oooo/' # Update with your path
18
 
19
  def getRenderCords(ta: list, idx: int, res: int = 1024, size: tuple = (1280, 720)) -> list:
20
  i = idx - res // 2
 
180
  ]
181
  subprocess.run(ffmpeg_cmd)
182
 
183
+ def gradio_interface(audio_file, output_name, fps=30, vidwidth=1280, vidhight=720, oscres=512):
184
+ resolution = f"{vidwidth}x{vidhight}"
185
  res = tuple(map(int, resolution.split('x')))
186
  main(audio_file, output_name, fps=fps, res=res, oscres=oscres)
187
  return f"Output video '{output_name}.mp4' has been created. Click the link to download."
 
 
188
 
189
  # Define Gradio interface
190
  iface = gr.Interface(
191
  fn=gradio_interface,
192
  inputs=[
193
+ gr.components.File(label="Upload your MP3 file"),
194
+ gr.components.Textbox(label="Output Video Name (without extension)"),
195
+ gr.components.Slider(label="Frames per Second", value=30, minimum=30, maximum=60, step=1),
196
+ gr.components.Slider(label="Output Video Width", value=1280, minimum=100, maximum=4096),
197
+ gr.components.Slider(label="Output Video Height", value=720, minimum=100, maximum=2160),
198
+ gr.components.Slider(label="Number of Visualization Segments", value=512, minimum=128, maximum=2048, step=2)
199
  ],
200
+ outputs=[gr.components.Textbox(label="Output")],
201
  title="MP3 to Video Visualization",
202
  description="Upload an MP3 file and configure parameters to create a visualization video."
203
  )