Skip to content

Commit

Permalink
调整项目结构,增加两个单独的 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
yqzhishen committed Mar 5, 2022
1 parent 1a89b9b commit 00308a9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ dmypy.json

# Others
/automation.py
/test.py
*.wav
*.mp3
*.mid
Expand Down
45 changes: 21 additions & 24 deletions autoxstudio.py → src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,29 @@
import win32con

import uiautomation as auto

logger = logging.getLogger()
import colorlog


def _init():
import colorlog
log_colors_config = {
'DEBUG': 'white',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'bold_red',
}
console_handler = logging.StreamHandler()
logger.setLevel(logging.INFO)
console_handler.setLevel(logging.INFO)
console_formatter = colorlog.ColoredFormatter(
fmt='%(log_color)s[%(asctime)s.%(msecs)03d] %(filename)s -> %(funcName)s line:%(lineno)d [%(levelname)s] : %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
log_colors=log_colors_config
)
console_handler.setFormatter(console_formatter)
if not logger.handlers:
logger.addHandler(console_handler)
console_handler.close()
logger = logging.getLogger()
log_colors_config = {
'DEBUG': 'white',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'bold_red',
}
console_handler = logging.StreamHandler()
logger.setLevel(logging.INFO)
console_handler.setLevel(logging.INFO)
console_formatter = colorlog.ColoredFormatter(
fmt='%(log_color)s[%(asctime)s.%(msecs)03d] %(filename)s -> %(funcName)s line:%(lineno)d [%(levelname)s] : %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
log_colors=log_colors_config
)
console_handler.setFormatter(console_formatter)
if not logger.handlers:
logger.addHandler(console_handler)
console_handler.close()


def _verify_startup():
Expand Down Expand Up @@ -383,7 +381,6 @@ def switch_singer(name: str, track: int = 1):


if __name__ == '__main__':
_init()
# demo: 导出同一个工程文件的不同歌手演唱音频(公测版歌手不全无法使用,目前仅可运行在 2.0.0 beta2 版本上)
singers = ['陈水若', '方念', '果妹', '小傻'] # 需要导出的所有歌手
path = r'PATH_TO_PROJECT' # 工程文件存放路径
Expand Down
21 changes: 21 additions & 0 deletions src/multi_exports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from core import *


if __name__ == '__main__':
# demo: 导出某文件夹下所有的工程
path = r'PATH_TO_PROJECTS'
filelist = []
for name in os.listdir(path):
if os.path.isfile(os.path.join(path, name)) and name.endswith('.svip'):
filelist.append(name)
num = len(filelist)
if num > 0:
start_xstudio(os.path.join(path, filelist[0]))
export_project(format='wav', samplerate=48000)
if num > 1:
open_project(filename=filelist[1], folder=path)
export_project(format='wav', samplerate=48000)
for file in filelist[2:]:
open_project(filename=file)
export_project(format='wav', samplerate=48000)
quit_xstudio()
13 changes: 13 additions & 0 deletions src/multi_singers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from core import *


if __name__ == '__main__':
# demo: 导出同一个工程文件的不同歌手演唱音频(公测版歌手不全无法使用,目前仅可运行在 2.0.0 beta2 版本上)
singers = ['陈水若', '方念', '果妹', '小傻'] # 需要导出的所有歌手
path = r'PATH_TO_PROJECT' # 工程文件存放路径
prefix = '示例' # 各歌手演唱音频的公共前缀。本例中保存为“示例 - 陈水若.mp3”,“示例 - 方念.mp3”等
start_xstudio(engine=r'E:\YQ数据空间\YQ实验室\实验室:XStudioSinger\内测\XStudioSinger_2.0.0_beta2.exe', project=path)
for s in singers:
switch_singer(track=1, name=s)
export_project(title=f'{prefix} - {s}')
quit_xstudio()

0 comments on commit 00308a9

Please sign in to comment.