-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.py
29 lines (22 loc) · 928 Bytes
/
run.py
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
import os
def str_to_bool(value: str) -> bool:
return value.lower() in ("true", "1", "y", "yes")
USE_GPU = str_to_bool(os.getenv("SBV2_API_LITE_USE_GPU", "false"))
VERBOSE = str_to_bool(os.getenv("SBV2_API_LITE_VERBOSE", "false"))
LOG_LEVEL = os.getenv("SBV2_API_LITE_LOG_LEVEL", "INFO").upper()
FFMPEG_PATH = os.getenv("SBV2_API_LITE_FFMPEG_PATH", "ffmpeg")
MP3_BITRATE = os.getenv("SBV2_API_LITE_MP3_BITRATE", "64k")
import logging
logger = logging.getLogger(__name__)
logging.basicConfig(
level=LOG_LEVEL,
format="%(asctime)s - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S"
)
from fastapi import FastAPI
from sbv2apilite.tts import StyleBertVits2TTS
from sbv2apilite.api import get_api_router
sbv2tts = StyleBertVits2TTS(use_gpu=USE_GPU, verbose=VERBOSE)
router = get_api_router(sbv2tts, MP3_BITRATE, FFMPEG_PATH)
app = FastAPI(title="Style-Bert-VITS2 API Lite")
app.include_router(router)