Update app.py
Browse files
app.py
CHANGED
@@ -32,12 +32,12 @@ def extract_yt_audio(it, video_url, video_file):
|
|
32 |
elif it == 'URL' and ("https://www" in video_url or "https://" in video_url or "www." in video_url):
|
33 |
response = requests.get(video_url)
|
34 |
video_data = io.BytesIO(response.content)
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
sample = AudioSegment.
|
41 |
elif it == 'URL':
|
42 |
sample = AudioSegment.from_file(video_url)
|
43 |
else:
|
|
|
32 |
elif it == 'URL' and ("https://www" in video_url or "https://" in video_url or "www." in video_url):
|
33 |
response = requests.get(video_url)
|
34 |
video_data = io.BytesIO(response.content)
|
35 |
+
with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as temp_file:
|
36 |
+
temp_file.write(video_data)
|
37 |
+
temp_file_path = temp_file.name
|
38 |
+
wav_file_path = temp_file_path.replace(".mp4", ".wav")
|
39 |
+
subprocess.run(["ffmpeg", "-i", temp_file_path, "-vn", "-acodec", "pcm_s16le", "-ar", "44100", "-ac", "2", wav_file_path])
|
40 |
+
sample = AudioSegment.from_wav(wav_file_path)
|
41 |
elif it == 'URL':
|
42 |
sample = AudioSegment.from_file(video_url)
|
43 |
else:
|