Spaces:
Sleeping
Sleeping
zhzluke96 commited on
Commit ·
4c19a5a
1
Parent(s): d8e7d56
update
Browse filesFiles changed (6)
- modules/api/impl/ping_api.py+7-1
- modules/api/utils.py+1-1
- modules/config.py+16
- modules/utils/constants.pyAdded+13
- modules/utils/git.pyAdded+59
- webui.py+26-5
12345678from modules.api import utils as api_utilsfrom modules.api.Api import APIManagerdef setup(app: APIManager):@app.get("/v1/ping", response_model=api_utils.BaseResponse)async def ping():return {"message": "ok", "data": "pong"}1234567891011121314from modules.api import utils as api_utilsfrom modules.api.Api import APIManagerfrom modules import configdef setup(app: APIManager):@app.get("/v1/ping", response_model=api_utils.BaseResponse)async def ping():return api_utils.success_response("pong")@app.get("/v1/versions", response_model=api_utils.BaseResponse)async def get_versions():return api_utils.success_response(config.versions.to_dict())
35 unmodified lines3637383940414235 unmodified lines}def success_response(data: Any, message: str = "Success") -> BaseResponse:return BaseResponse(message=message, data=data)35 unmodified lines3637383940414235 unmodified lines}def success_response(data: Any, message: str = "ok") -> BaseResponse:return BaseResponse(message=message, data=data)
12345from modules.utils.JsonObject import JsonObjectruntime_env_vars = JsonObject({})api = None123456789101112131415161718192021import sysimport torchfrom modules.utils.JsonObject import JsonObjectfrom modules.utils import gitruntime_env_vars = JsonObject({})api = Noneversions = JsonObject({"python_version": ".".join([str(x) for x in sys.version_info[0:3]]),"torch_version": getattr(torch, "__long_version__", torch.__version__),# "gradio_version":gr.__version__,"git_tag": git.git_tag(),"git_branch": git.branch_name(),"git_commit": git.commit_hash(),})
12345678910111213import os
cwd = os.getcwd()utils_path = os.path.dirname(os.path.realpath(__file__))modules_path = os.path.dirname(utils_path)
ROOT_DIR = os.path.dirname(modules_path)DATA_DIR = os.path.join(ROOT_DIR, "data")
MODELS_DIR = os.path.join(ROOT_DIR, "models")
speakers_dir = os.path.join(DATA_DIR, "speakers")1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859from functools import lru_cacheimport osimport subprocess
from modules.utils import constants
git = os.environ.get("GIT", "git")
@lru_cache()def commit_hash(): try: return subprocess.check_output( [git, "-C", constants.ROOT_DIR, "rev-parse", "HEAD"], shell=False, encoding="utf8", ).strip() except Exception: return "<none>"
@lru_cache()def git_tag(): try: return subprocess.check_output( [git, "-C", constants.ROOT_DIR, "describe", "--tags"], shell=False, encoding="utf8", ).strip() except Exception: try:
changelog_md = os.path.join( os.path.dirname(os.path.dirname(__file__)), "CHANGELOG.md" ) with open(changelog_md, "r", encoding="utf-8") as file: line = next((line.strip() for line in file if line.strip()), "<none>") line = line.replace("## ", "") return line except Exception: return "<none>"
@lru_cache()def branch_name(): try: return subprocess.check_output( [git, "-C", constants.ROOT_DIR, "rev-parse", "--abbrev-ref", "HEAD"], shell=False, encoding="utf8", ).strip() except Exception: return "<none>"
if __name__ == "__main__": print(commit_hash()) print(git_tag()) print(branch_name())12 unmodified lines131415161718192021222324157 unmodified lines182183184185186187188418 unmodified lines607608609610611612166 unmodified lines77978078178278378421 unmodified lines80680780880981081111 unmodified lines82382482582682782882983083112 unmodified linesimport osimport loggingimport numpy as npfrom modules.devices import devicesfrom modules.synthesize_audio import synthesize_audiofrom modules.utils.cache import conditional_cachelogging.basicConfig(level=os.getenv("LOG_LEVEL", "INFO"),157 unmodified linesdef read_local_readme():with open("README.md", "r", encoding="utf-8") as file:content = file.read()content = content[content.index("# 🗣️ ChatTTS-Forge") :]return content418 unmodified linesreturn ssml_inputdef split_long_text(long_text_input):spliter = SentenceSplitter(webui_config["spliter_threshold"])sentences = spliter.parse(long_text_input)166 unmodified linesgr.Markdown(readme_content)def create_interface():js_func = """21 unmodified lines#input_title div.eta-bar {display: none !important; transform: none !important;}</style>"""11 unmodified lineswith gr.TabItem("README"):create_readme_tab()gr.Markdown("此项目基于 [ChatTTS-Forge](https://github.com/lenML/ChatTTS-Forge) ")return demo12 unmodified lines131415161718192021222324157 unmodified lines182183184185186187188418 unmodified lines607608609610611612613614166 unmodified lines78178278378478578678778878979079179279379479579679779879980080180280380421 unmodified lines82682782882983083183283383411 unmodified lines84684784884985085185212 unmodified linesimport osimport loggingimport sysimport numpy as npfrom modules.devices import devicesfrom modules.synthesize_audio import synthesize_audiologging.basicConfig(level=os.getenv("LOG_LEVEL", "INFO"),157 unmodified linesdef read_local_readme():with open("README.md", "r", encoding="utf-8") as file:content = file.read()content = content[content.index("# ") :]return content418 unmodified linesreturn ssml_input# NOTE: 这个其实是需要GPU的...但是spaces会自动卸载,所以不太好使,具体处理在text_normalize中兼容# @spaces.GPUdef split_long_text(long_text_input):spliter = SentenceSplitter(webui_config["spliter_threshold"])sentences = spliter.parse(long_text_input)166 unmodified linesgr.Markdown(readme_content)def create_app_footer():gradio_version = gr.__version__git_tag = config.versions.git_taggit_commit = config.versions.git_commitgit_branch = config.versions.git_branchpython_version = config.versions.python_versiontorch_version = config.versions.torch_versionconfig.versions.gradio_version = gradio_versiongr.Markdown(f"""🍦 [ChatTTS-Forge](https://github.com/lenML/ChatTTS-Forge)version: [{git_tag}](https://github.com/lenML/ChatTTS-Forge/commit/{git_commit}) | branch: `{git_branch}` | python: `{python_version}` | torch: `{torch_version}`""")def create_interface():js_func = """21 unmodified lines#input_title div.eta-bar {display: none !important; transform: none !important;}footer {display: none !important;}</style>"""11 unmodified lineswith gr.TabItem("README"):create_readme_tab()create_app_footer()return demo
modules/api/impl/ping_api.py+7-1
modules/api/utils.py+1-1
modules/config.py+16
modules/utils/constants.pyAdded+13
modules/utils/git.pyAdded+59
webui.py+26-5