Spaces:
Build error
Build error
Alex Volkov
commited on
Commit
•
352eb01
1
Parent(s):
f1f3adb
Args now sit in a package
Browse files- app.py +4 -14
- download.py +3 -10
- utils/utils.py +17 -1
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
from download import check_download, download, download_generator
|
4 |
import argparse
|
5 |
import anvil.media
|
@@ -8,26 +7,17 @@ import pathlib
|
|
8 |
from pathlib import Path
|
9 |
from shutil import rmtree
|
10 |
import dotenv
|
11 |
-
from utils.utils import
|
12 |
-
import whisper
|
13 |
|
14 |
dotenv.load_dotenv()
|
15 |
|
16 |
anvil.server.connect(os.environ.get('ANVIL_UPLINK_KEY'))
|
17 |
queue_placeholder = None
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
parser.add_argument("--public", type=str2bool, default=False,
|
22 |
-
help="Wether to share with gradio public or not")
|
23 |
-
parser.add_argument("--preload", type=str2bool, default=True,
|
24 |
-
help="Should the model be preloaded on script launch. Disable for faster debug")
|
25 |
-
parser.add_argument("--model", default="medium",
|
26 |
-
choices=whisper.available_models(), help="name of the Whisper model to use")
|
27 |
-
|
28 |
-
args = parser.parse_args().__dict__
|
29 |
-
gradio_share: str = args.get("public")
|
30 |
model_size: str = args.get("model")
|
|
|
31 |
|
32 |
url_input = gr.Textbox(label="Youtube/Twitter/etc video URL (supports many services)", value='https://twitter.com/starsonxh/status/1552945347194142720', lines=1, elem_id="url_input")
|
33 |
download_status = gr.Textbox(label="Status:", value='', lines=1, elem_id="download_status")
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from download import check_download, download, download_generator
|
3 |
import argparse
|
4 |
import anvil.media
|
|
|
7 |
from pathlib import Path
|
8 |
from shutil import rmtree
|
9 |
import dotenv
|
10 |
+
from utils.utils import get_args
|
|
|
11 |
|
12 |
dotenv.load_dotenv()
|
13 |
|
14 |
anvil.server.connect(os.environ.get('ANVIL_UPLINK_KEY'))
|
15 |
queue_placeholder = None
|
16 |
|
17 |
+
args = get_args()
|
18 |
+
gradio_share: bool = args.get("public")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
model_size: str = args.get("model")
|
20 |
+
preload_model: str = args.get("preload")
|
21 |
|
22 |
url_input = gr.Textbox(label="Youtube/Twitter/etc video URL (supports many services)", value='https://twitter.com/starsonxh/status/1552945347194142720', lines=1, elem_id="url_input")
|
23 |
download_status = gr.Textbox(label="Status:", value='', lines=1, elem_id="download_status")
|
download.py
CHANGED
@@ -14,21 +14,14 @@ import whisper
|
|
14 |
from whisper.tokenizer import LANGUAGES
|
15 |
import ffmpeg
|
16 |
from utils.subs import bake_subs
|
17 |
-
from utils.utils import
|
18 |
|
19 |
original_dir = os.getcwd()
|
20 |
output_dir = Path('output')
|
21 |
|
22 |
-
|
23 |
-
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
24 |
-
parser.add_argument("--preload", type=str2bool, default=True,
|
25 |
-
help="Should the model be preloaded on script launch. Disable for faster debug")
|
26 |
-
parser.add_argument("--model", default="medium",
|
27 |
-
choices=whisper.available_models(), help="name of the Whisper model to use")
|
28 |
-
|
29 |
-
args = parser.parse_args().__dict__
|
30 |
model_size: str = args.get("model")
|
31 |
-
preload_model:
|
32 |
|
33 |
if preload_model:
|
34 |
print("Preloading model")
|
|
|
14 |
from whisper.tokenizer import LANGUAGES
|
15 |
import ffmpeg
|
16 |
from utils.subs import bake_subs
|
17 |
+
from utils.utils import get_args
|
18 |
|
19 |
original_dir = os.getcwd()
|
20 |
output_dir = Path('output')
|
21 |
|
22 |
+
args = get_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
model_size: str = args.get("model")
|
24 |
+
preload_model: bool = args.get("preload")
|
25 |
|
26 |
if preload_model:
|
27 |
print("Preloading model")
|
utils/utils.py
CHANGED
@@ -1,7 +1,23 @@
|
|
|
|
|
|
1 |
def str2bool(string):
|
2 |
str2val = {"True": True, "False": False}
|
3 |
if string in str2val:
|
4 |
return str2val[string]
|
5 |
else:
|
6 |
raise ValueError(
|
7 |
-
f"Expected one of {set(str2val.keys())}, got {string}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import whisper
|
2 |
+
import argparse
|
3 |
def str2bool(string):
|
4 |
str2val = {"True": True, "False": False}
|
5 |
if string in str2val:
|
6 |
return str2val[string]
|
7 |
else:
|
8 |
raise ValueError(
|
9 |
+
f"Expected one of {set(str2val.keys())}, got {string}")
|
10 |
+
|
11 |
+
def get_args():
|
12 |
+
parser = argparse.ArgumentParser(
|
13 |
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
14 |
+
parser.add_argument("--public", type=str2bool, default=False,
|
15 |
+
help="Wether to share with gradio public or not")
|
16 |
+
parser.add_argument("--preload", type=str2bool, default=True,
|
17 |
+
help="Should the model be preloaded on script launch. Disable for faster debug")
|
18 |
+
parser.add_argument("--model", default="medium",
|
19 |
+
choices=whisper.available_models(), help="name of the Whisper model to use")
|
20 |
+
|
21 |
+
args = parser.parse_args().__dict__
|
22 |
+
return args
|
23 |
+
|