Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,22 +3,23 @@ import yt_dlp
|
|
| 3 |
import whisper
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
}
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
def process_video(url, cookies_path):
|
| 24 |
audio_file = download_audio(url, cookies_path)
|
|
|
|
| 3 |
import whisper
|
| 4 |
import tempfile
|
| 5 |
|
| 6 |
+
import os
|
| 7 |
+
import yt_dlp
|
| 8 |
+
|
| 9 |
+
def download_audio(url):
|
| 10 |
+
cookies_path = os.path.join(os.getenv('HF_HOME', '/home/user/app'), 'cookies.txt')
|
| 11 |
+
ydl_opts = {
|
| 12 |
+
'format': 'bestaudio/best',
|
| 13 |
+
'outtmpl': 'audio.%(ext)s',
|
| 14 |
+
'postprocessors': [{
|
| 15 |
+
'key': 'FFmpegExtractAudio',
|
| 16 |
+
'preferredcodec': 'wav',
|
| 17 |
+
'preferredquality': '192',
|
| 18 |
+
}],
|
| 19 |
+
'cookiefile': cookies_path
|
| 20 |
+
}
|
| 21 |
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
| 22 |
+
ydl.download([url])
|
| 23 |
|
| 24 |
def process_video(url, cookies_path):
|
| 25 |
audio_file = download_audio(url, cookies_path)
|