2023-02-17 00:08:27 +00:00
|
|
|
import os
|
|
|
|
|
|
|
|
if 'TORTOISE_MODELS_DIR' not in os.environ:
|
|
|
|
os.environ['TORTOISE_MODELS_DIR'] = os.path.realpath(os.path.join(os.getcwd(), './models/tortoise/'))
|
|
|
|
|
|
|
|
if 'TRANSFORMERS_CACHE' not in os.environ:
|
|
|
|
os.environ['TRANSFORMERS_CACHE'] = os.path.realpath(os.path.join(os.getcwd(), './models/transformers/'))
|
|
|
|
|
2023-03-22 19:24:53 +00:00
|
|
|
os.environ['PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION'] = 'python'
|
|
|
|
|
2023-02-24 23:13:13 +00:00
|
|
|
from utils import *
|
|
|
|
from webui import *
|
|
|
|
|
2023-02-17 00:08:27 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
args = setup_args()
|
|
|
|
|
|
|
|
if args.listen_path is not None and args.listen_path != "/":
|
|
|
|
import uvicorn
|
|
|
|
uvicorn.run("main:app", host=args.listen_host, port=args.listen_port if not None else 8000)
|
|
|
|
else:
|
|
|
|
webui = setup_gradio()
|
|
|
|
webui.launch(share=args.share, prevent_thread_lock=True, show_error=True, server_name=args.listen_host, server_port=args.listen_port)
|
2023-02-17 20:43:12 +00:00
|
|
|
if not args.defer_tts_load:
|
|
|
|
tts = setup_tortoise()
|
2023-02-17 00:08:27 +00:00
|
|
|
|
|
|
|
webui.block_thread()
|
|
|
|
elif __name__ == "main":
|
|
|
|
from fastapi import FastAPI
|
|
|
|
import gradio as gr
|
|
|
|
|
|
|
|
import sys
|
|
|
|
sys.argv = [sys.argv[0]]
|
|
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
args = setup_args()
|
|
|
|
webui = setup_gradio()
|
|
|
|
app = gr.mount_gradio_app(app, webui, path=args.listen_path)
|
|
|
|
|
2023-02-17 20:43:12 +00:00
|
|
|
if not args.defer_tts_load:
|
|
|
|
tts = setup_tortoise()
|