Spaces:
Running
Running
File size: 2,874 Bytes
04ffec9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
import os
import asyncio
import logging
from argparse import Namespace
from bark.mode_load import set_bark_model_load_logger
from speakers.common.log import get_logger, set_log_level
from speakers import set_main_logger, Speaker, WebSpeaker
from speakers.processors.bark_to_voice import set_bark_to_voice_logger
from speakers.processors.rvc_speakers_processor import set_rvc_speakers_logger
from speakers.processors.vits_to_voice import set_vits_to_voice_logger
from speakers.server.servlet.runner import set_server_runner_logger
from speakers.server.model.flow_data import PayLoad
from speakers.server import dispatch as dispatch_web
import argparse
logger = logging.getLogger('start_logger')
def set_start_logger(l):
global logger
logger = l
async def dispatch(args: Namespace):
args_dict = vars(args)
logger.info(f'Running in {args.mode} mode')
if args.mode in 'demo':
speaker = Speaker(speakers_config_file=args.speakers_config_file, verbose=args.verbose)
await speaker.preparation_runner(task_id="0", payload=PayLoad())
elif args.mode in 'web':
await dispatch_web(speakers_config_file=args.speakers_config_file)
elif args.mode in 'web_runner':
translator = WebSpeaker(speakers_config_file=args.speakers_config_file, verbose=args.verbose, nonce=args.nonce)
await translator.listen()
def main():
parser = argparse.ArgumentParser(prog='speakers',
description='S')
parser.add_argument('-m', '--mode', default='demo', type=str, choices=['demo', 'web', 'web_runner'],
help='Run ')
parser.add_argument('-v', '--verbose', action='store_true', help='Print debug info in result folder')
parser.add_argument("--speakers-config-file", type=str, default="speakers.yaml")
parser.add_argument('--nonce', default='', type=str, help='Used by web module to decide which secret for securing '
'internal web server communication')
args = None
try:
args = parser.parse_args()
set_log_level(level=logging.DEBUG if args.verbose else logging.INFO)
set_start_logger(get_logger(args.mode))
set_main_logger(logger)
set_bark_model_load_logger(logger)
set_rvc_speakers_logger(logger)
set_vits_to_voice_logger(logger)
set_bark_to_voice_logger(logger)
set_server_runner_logger(logger)
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(dispatch(args))
except KeyboardInterrupt:
if not args or args.mode != 'web':
print()
except Exception as e:
logger.error(f'{e.__class__.__name__}: {e}',
exc_info=e if args and args.verbose else None)
if __name__ == '__main__':
main()
|