Merge pull request #98 from JSchmie/bug_fix_before_v0.2
Bug fix before v0.2
This commit is contained in:
+9
-49
@@ -5,17 +5,12 @@ The function includes arguments for specifying the audio files, model paths,
|
||||
output formats, and other options necessary for transcription.
|
||||
"""
|
||||
import os
|
||||
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
|
||||
import json
|
||||
|
||||
from .autotranscript import Scraibe
|
||||
from .misc import ParseKwargs
|
||||
|
||||
|
||||
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
|
||||
from whisper.tokenizer import LANGUAGES, TO_LANGUAGE_CODE
|
||||
from torch.cuda import is_available
|
||||
from torch import set_num_threads
|
||||
|
||||
from .autotranscript import Scraibe
|
||||
|
||||
def cli():
|
||||
"""
|
||||
@@ -37,21 +32,12 @@ def cli():
|
||||
|
||||
parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
|
||||
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
|
||||
parser.add_argument("-f", "--audio-files", nargs="+", type=str, default=None,
|
||||
help="List of audio files to transcribe.")
|
||||
|
||||
group.add_argument('--start-server', action='store_true',
|
||||
help='Start the Gradio app.'
|
||||
'If set, all other arguments are ignored'
|
||||
'besides --server-config or --server-kwargs.')
|
||||
|
||||
parser.add_argument("--server-config", type=str, default=None,
|
||||
help="Path to the configy.yml file.")
|
||||
|
||||
parser.add_argument('--server-kwargs', nargs='*', action=ParseKwargs, default={},
|
||||
help='Keyword arguments for the Gradio app.')
|
||||
parser.add_argument("--whisper-type", type=str, default="whisper",
|
||||
choices=["whisper", "whisperx"],
|
||||
help="Type of Whisper model to use ('whisper' or 'whisperx').")
|
||||
|
||||
parser.add_argument("--whisper-model-name", default="medium",
|
||||
help="Name of the Whisper model to use.")
|
||||
@@ -83,7 +69,7 @@ def cli():
|
||||
parser.add_argument("--verbose-output", type=str2bool, default=True,
|
||||
help="Enable or disable progress and debug messages.")
|
||||
|
||||
parser.add_argument("--task", type=str, default='autotranscribe', # unifinished code
|
||||
parser.add_argument("--task", type=str, default='autotranscribe',
|
||||
choices=["autotranscribe", "diarization",
|
||||
"autotranscribe+translate", "translate", 'transcribe'],
|
||||
help="Choose to perform transcription, diarization, or translation. \
|
||||
@@ -104,22 +90,20 @@ def cli():
|
||||
|
||||
out_format = arg_dict.pop("output_format")
|
||||
|
||||
# seup server arg:
|
||||
start_server = arg_dict.pop("start_server")
|
||||
|
||||
task = arg_dict.pop("task")
|
||||
|
||||
if args.num_threads > 0:
|
||||
set_num_threads(arg_dict.pop("num_threads"))
|
||||
|
||||
class_kwargs = {'whisper_model': arg_dict.pop("whisper_model_name"),
|
||||
'whisper_type':arg_dict.pop("whisper_type"),
|
||||
'dia_model': arg_dict.pop("diarization_directory"),
|
||||
'use_auth_token': arg_dict.pop("hf_token")}
|
||||
'use_auth_token': arg_dict.pop("hf_token"),
|
||||
}
|
||||
|
||||
if arg_dict["whisper_model_directory"]:
|
||||
class_kwargs["download_root"] = arg_dict.pop("whisper_model_directory")
|
||||
|
||||
if not start_server:
|
||||
|
||||
model = Scraibe(**class_kwargs)
|
||||
|
||||
@@ -166,29 +150,5 @@ def cli():
|
||||
with open(path, "w") as f:
|
||||
f.write(out)
|
||||
|
||||
else: # unfinished code
|
||||
raise NotImplementedError("Currently not Working")
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
execute_path = os.path.join(
|
||||
os.path.dirname(__file__), "app/app_starter.py")
|
||||
|
||||
config = arg_dict.pop("server_config")
|
||||
server_kwargs = arg_dict.pop("server_kwargs")
|
||||
|
||||
if not config:
|
||||
subprocess.run([sys.executable, execute_path,
|
||||
f"--server-kwargs={server_kwargs}"])
|
||||
elif not server_kwargs:
|
||||
subprocess.run([sys.executable, execute_path,
|
||||
f"--server-config={config}"])
|
||||
elif not config and not server_kwargs:
|
||||
subprocess.run([sys.executable, execute_path])
|
||||
else:
|
||||
subprocess.run([sys.executable, execute_path,
|
||||
f"--server-config={config}", f"--server-kwargs={server_kwargs}"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
||||
Reference in New Issue
Block a user