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