jhj0517 commited on
Commit
6960e0b
·
unverified ·
2 Parent(s): 825f362 8a8890b

Merge pull request #218 from jhj0517/refactor/edit-args

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -304,20 +304,18 @@ class App:
304
  outputs=None)
305
 
306
  # Launch the app with optional gradio settings
307
- launch_args = {}
308
- if self.args.share:
309
- launch_args['share'] = self.args.share
310
- if self.args.server_name:
311
- launch_args['server_name'] = self.args.server_name
312
- if self.args.server_port:
313
- launch_args['server_port'] = self.args.server_port
314
- if self.args.username and self.args.password:
315
- launch_args['auth'] = (self.args.username, self.args.password)
316
- if self.args.root_path:
317
- launch_args['root_path'] = self.args.root_path
318
- launch_args['inbrowser'] = True
319
-
320
- self.app.queue(api_open=False).launch(**launch_args)
321
 
322
  @staticmethod
323
  def open_folder(folder_path: str):
@@ -347,7 +345,8 @@ parser.add_argument('--username', type=str, default=None, help='Gradio authentic
347
  parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
348
  parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
349
  parser.add_argument('--colab', type=bool, default=False, nargs='?', const=True, help='Is colab user or not')
350
- parser.add_argument('--api_open', type=bool, default=False, nargs='?', const=True, help='enable api or not')
 
351
  parser.add_argument('--whisper_model_dir', type=str, default=os.path.join("models", "Whisper"),
352
  help='Directory path of the whisper model')
353
  parser.add_argument('--faster_whisper_model_dir', type=str, default=os.path.join("models", "Whisper", "faster-whisper"),
 
304
  outputs=None)
305
 
306
  # Launch the app with optional gradio settings
307
+ args = self.args
308
+
309
+ self.app.queue(
310
+ api_open=args.api_open
311
+ ).launch(
312
+ share=args.share,
313
+ server_name=args.server_name,
314
+ server_port=args.server_port,
315
+ auth=(args.username, args.password) if args.username and args.password else None,
316
+ root_path=args.root_path,
317
+ inbrowser=args.inbrowser
318
+ )
 
 
319
 
320
  @staticmethod
321
  def open_folder(folder_path: str):
 
345
  parser.add_argument('--password', type=str, default=None, help='Gradio authentication password')
346
  parser.add_argument('--theme', type=str, default=None, help='Gradio Blocks theme')
347
  parser.add_argument('--colab', type=bool, default=False, nargs='?', const=True, help='Is colab user or not')
348
+ parser.add_argument('--api_open', type=bool, default=False, nargs='?', const=True, help='Enable api or not in Gradio')
349
+ parser.add_argument('--inbrowser', type=bool, default=True, nargs='?', const=True, help='Whether to automatically start Gradio app or not')
350
  parser.add_argument('--whisper_model_dir', type=str, default=os.path.join("models", "Whisper"),
351
  help='Directory path of the whisper model')
352
  parser.add_argument('--faster_whisper_model_dir', type=str, default=os.path.join("models", "Whisper", "faster-whisper"),