jpjp9292 commited on
Commit
3db36f3
Β·
verified Β·
1 Parent(s): c008b2c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -1,9 +1,7 @@
1
-
2
-
3
-
4
  import os
5
  import gradio as gr
6
  from moviepy.editor import VideoFileClip
 
7
 
8
  def convert_mp4_to_mp3(video_file_path, output_dir):
9
  # MP3 λ³€ν™˜ κ³Όμ •
@@ -16,18 +14,23 @@ def convert_mp4_to_mp3(video_file_path, output_dir):
16
  return output_path
17
 
18
  def mp4_to_mp3_converter(video_file):
 
 
 
 
19
  # λΉ„λ””μ˜€ 파일이 없을 λ•Œ 처리
20
  if video_file is None:
21
  return "Error: No video file was uploaded."
22
 
 
23
  modeltarget = "mp4_to_mp3_conversion"
24
  save_path = os.path.join("/home/user/app", modeltarget)
25
  os.makedirs(save_path, exist_ok=True)
26
 
27
- # λΉ„λ””μ˜€ 파일 κ²½λ‘œκ°€ μ˜¬λ°”λ₯Έμ§€ 확인 ν›„ λ³€ν™˜
28
  try:
29
  mp3_file_path = convert_mp4_to_mp3(video_file.name, save_path)
30
- return mp3_file_path
31
  except Exception as e:
32
  return f"Error occurred during conversion: {str(e)}"
33
 
@@ -35,9 +38,9 @@ def mp4_to_mp3_converter(video_file):
35
  iface = gr.Interface(
36
  fn=mp4_to_mp3_converter,
37
  inputs=gr.File(label="Input Video"),
38
- outputs="text", # 였λ₯˜ λ©”μ‹œμ§€ λ˜λŠ” 파일 경둜 λ°˜ν™˜
39
  title="MP4 to MP3 Converter",
40
- description="Upload a video file to convert it to MP3 format."
41
  )
42
 
43
  if __name__ == "__main__":
 
 
 
 
1
  import os
2
  import gradio as gr
3
  from moviepy.editor import VideoFileClip
4
+ from datetime import datetime
5
 
6
  def convert_mp4_to_mp3(video_file_path, output_dir):
7
  # MP3 λ³€ν™˜ κ³Όμ •
 
14
  return output_path
15
 
16
  def mp4_to_mp3_converter(video_file):
17
+ # μ—…λ‘œλ“œ μ‹œκ°„ ν‘œμ‹œ
18
+ upload_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
19
+ print(f"File uploaded at: {upload_time}")
20
+
21
  # λΉ„λ””μ˜€ 파일이 없을 λ•Œ 처리
22
  if video_file is None:
23
  return "Error: No video file was uploaded."
24
 
25
+ # μ €μž₯ 경둜 μ„€μ •
26
  modeltarget = "mp4_to_mp3_conversion"
27
  save_path = os.path.join("/home/user/app", modeltarget)
28
  os.makedirs(save_path, exist_ok=True)
29
 
30
+ # MP3 λ³€ν™˜ ν›„ 파일 경둜 λ°˜ν™˜
31
  try:
32
  mp3_file_path = convert_mp4_to_mp3(video_file.name, save_path)
33
+ return mp3_file_path # λ‹€μš΄λ‘œλ“œλ₯Ό μœ„ν•œ 파일 경둜 λ°˜ν™˜
34
  except Exception as e:
35
  return f"Error occurred during conversion: {str(e)}"
36
 
 
38
  iface = gr.Interface(
39
  fn=mp4_to_mp3_converter,
40
  inputs=gr.File(label="Input Video"),
41
+ outputs=gr.File(label="Download MP3"), # λ‹€μš΄λ‘œλ“œ κ°€λŠ₯ν•œ 파일 좜λ ₯
42
  title="MP4 to MP3 Converter",
43
+ description="Upload a video file to convert it to MP3 format. Upload time will be displayed in the console."
44
  )
45
 
46
  if __name__ == "__main__":