Spaces:
Runtime error
Runtime error
Update audioex.py
Browse files- audioex.py +7 -28
audioex.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
-
import subprocess
|
2 |
import os
|
3 |
-
import
|
4 |
|
5 |
def ex():
|
6 |
print("Started ex")
|
@@ -13,30 +12,10 @@ def ex():
|
|
13 |
print(mp4_file_path)
|
14 |
os.rename(mp4_file_path, "video.mp4")
|
15 |
print("Command started")
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
print(f"Return code: {e.returncode}")
|
23 |
-
print(f"Output: {e.output}")
|
24 |
-
|
25 |
-
try:
|
26 |
-
command2mp3 = ["ffmpeg", "-i", "video.mp4", "speech.mp3"]
|
27 |
-
result1 = subprocess.run(command2mp3, capture_output=True, text=True, check=True, shell=True)
|
28 |
-
print("Command Output of mp3 conversion:\n", result1.stdout)
|
29 |
-
except subprocess.CalledProcessError as e:
|
30 |
-
print(f"Error converting to MP3: {e}")
|
31 |
-
print(f"Return code: {e.returncode}")
|
32 |
-
print(f"Output: {e.output}")
|
33 |
-
|
34 |
-
try:
|
35 |
-
command2wav = ["ffmpeg", "-i", "speech.mp3", "speech.wav"]
|
36 |
-
result2 = subprocess.run(command2wav, capture_output=True, text=True, check=True, shell=True)
|
37 |
-
print("Command Output of wav conversion:\n", result2.stdout)
|
38 |
-
except subprocess.CalledProcessError as e:
|
39 |
-
print(f"Error converting to WAV: {e}")
|
40 |
-
print(f"Return code: {e.returncode}")
|
41 |
-
print(f"Output: {e.output}")
|
42 |
print("Command ended")
|
|
|
|
|
1 |
import os
|
2 |
+
from moviepy.editor import VideoFileClip
|
3 |
|
4 |
def ex():
|
5 |
print("Started ex")
|
|
|
12 |
print(mp4_file_path)
|
13 |
os.rename(mp4_file_path, "video.mp4")
|
14 |
print("Command started")
|
15 |
+
video = VideoFileClip("video.mp4")
|
16 |
+
audio = video.audio
|
17 |
+
audio.write_audiofile("speech.wav")
|
18 |
+
audio.close()
|
19 |
+
video.close()
|
20 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
print("Command ended")
|