Spaces:
Sleeping
Sleeping
Commit ·
f0d211a
1
Parent(s): ea1f73d
Upload 2 files
Browse files- app.py +28 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#import os
|
| 2 |
+
#os.system("python -m pip install --upgrade pip")
|
| 3 |
+
#os.system("pip uninstall -y gradio")
|
| 4 |
+
#os.system("pip install gradio==3.28.3")
|
| 5 |
+
import gradio as gr
|
| 6 |
+
from moviepy.editor import *
|
| 7 |
+
import base64
|
| 8 |
+
|
| 9 |
+
def mp4_to_mp3(mp4):
|
| 10 |
+
mp4_without_frames = AudioFileClip(mp4)
|
| 11 |
+
mp4_without_frames.write_audiofile("audio.mp3")
|
| 12 |
+
mp4_without_frames.close()
|
| 13 |
+
with open('audio.mp3', 'rb') as file:
|
| 14 |
+
mp3 = file.read()
|
| 15 |
+
base64_mp3 = base64.b64encode(mp3).decode('utf-8')
|
| 16 |
+
return base64_mp3
|
| 17 |
+
|
| 18 |
+
input_video = gr.Video(source="upload", type="filepath")
|
| 19 |
+
output_text = gr.Textbox()
|
| 20 |
+
|
| 21 |
+
interface = gr.Interface(
|
| 22 |
+
fn=mp4_to_mp3,
|
| 23 |
+
inputs=input_video,
|
| 24 |
+
outputs=output_text,
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
interface.launch()
|
| 28 |
+
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
moviepy
|