Fix: colab stdout error, so replace with stdout wrapper
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import argparse
|
||||
import sys
|
||||
from multiprocessing import Pool
|
||||
|
||||
import torch
|
||||
@@ -10,6 +9,7 @@ import commons
|
||||
import utils
|
||||
from config import config
|
||||
from text import cleaned_text_to_sequence, get_bert
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
|
||||
def process_line(x):
|
||||
@@ -76,7 +76,7 @@ if __name__ == "__main__":
|
||||
for _ in tqdm(
|
||||
pool.imap_unordered(process_line, zip(lines, add_blank)),
|
||||
total=len(lines),
|
||||
file=sys.stdout,
|
||||
file=get_stdout(),
|
||||
):
|
||||
# 这里是缩进的代码块,表示循环体
|
||||
pass # 使用pass语句作为占位符
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
from random import shuffle
|
||||
from typing import Optional
|
||||
@@ -10,6 +9,7 @@ from tqdm import tqdm
|
||||
|
||||
from config import config
|
||||
from text.cleaner import clean_text
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
preprocess_text_config = config.preprocess_text_config
|
||||
|
||||
@@ -52,7 +52,7 @@ def preprocess(
|
||||
lines = trans_file.readlines()
|
||||
# print(lines, ' ', len(lines))
|
||||
if len(lines) != 0:
|
||||
for line in tqdm(lines, file=sys.stdout):
|
||||
for line in tqdm(lines, file=get_stdout()):
|
||||
try:
|
||||
utt, spk, language, text = line.strip().split("|")
|
||||
norm_text, phones, tones, word2ph = clean_text(
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from multiprocessing import Pool, cpu_count
|
||||
|
||||
import librosa
|
||||
@@ -10,6 +9,7 @@ from tqdm import tqdm
|
||||
|
||||
from config import config
|
||||
from tools.log import logger
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
|
||||
def normalize_audio(data, sr):
|
||||
@@ -88,7 +88,7 @@ if __name__ == "__main__":
|
||||
|
||||
pool = Pool(processes=processes)
|
||||
for _ in tqdm(
|
||||
pool.imap_unordered(process, tasks), file=sys.stdout, total=len(tasks)
|
||||
pool.imap_unordered(process, tasks), file=get_stdout(), total=len(tasks)
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
5
slice.py
5
slice.py
@@ -1,12 +1,13 @@
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import soundfile as sf
|
||||
import torch
|
||||
from tqdm import tqdm
|
||||
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
vad_model, utils = torch.hub.load(
|
||||
repo_or_dir="snakers4/silero-vad",
|
||||
model="silero_vad",
|
||||
@@ -106,7 +107,7 @@ if __name__ == "__main__":
|
||||
shutil.rmtree(output_dir)
|
||||
|
||||
total_sec = 0
|
||||
for wav_file in tqdm(wav_files, file=sys.stdout):
|
||||
for wav_file in tqdm(wav_files, file=get_stdout()):
|
||||
time_sec = split_wav(
|
||||
wav_file,
|
||||
output_dir,
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import argparse
|
||||
import concurrent.futures
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
@@ -9,6 +8,7 @@ from tqdm import tqdm
|
||||
|
||||
import utils
|
||||
from config import config
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
warnings.filterwarnings("ignore", category=UserWarning)
|
||||
from pyannote.audio import Inference, Model
|
||||
@@ -59,7 +59,7 @@ if __name__ == "__main__":
|
||||
tqdm(
|
||||
executor.map(save_style_vector, wavnames),
|
||||
total=len(wavnames),
|
||||
file=sys.stdout,
|
||||
file=get_stdout(),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
logger封装
|
||||
"""
|
||||
from loguru import logger
|
||||
import sys
|
||||
|
||||
from .stdout_wrapper import get_stdout
|
||||
|
||||
# 移除所有默认的处理器
|
||||
logger.remove()
|
||||
@@ -13,4 +13,4 @@ log_format = (
|
||||
"<g>{time:MM-DD HH:mm:ss}</g> |<lvl>{level:^8}</lvl>| {file}:{line} | {message}"
|
||||
)
|
||||
|
||||
logger.add(sys.stdout, format=log_format, backtrace=True, diagnose=True)
|
||||
logger.add(get_stdout(), format=log_format, backtrace=True, diagnose=True)
|
||||
|
||||
@@ -2,6 +2,7 @@ import subprocess
|
||||
import sys
|
||||
|
||||
from .log import logger
|
||||
from .stdout_wrapper import get_stdout
|
||||
|
||||
python = sys.executable
|
||||
|
||||
@@ -10,7 +11,7 @@ def run_script_with_log(cmd: list[str]) -> tuple[bool, str]:
|
||||
logger.info(f"Running: {' '.join(cmd)}")
|
||||
result = subprocess.run(
|
||||
[python] + cmd,
|
||||
stdout=sys.stdout,
|
||||
stdout=get_stdout(), # type: ignore
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
|
||||
@@ -4,7 +4,6 @@ import gc
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
import torch
|
||||
import torch.distributed as dist
|
||||
@@ -29,6 +28,7 @@ from mel_processing import mel_spectrogram_torch, spec_to_mel_torch
|
||||
from models import DurationDiscriminator, MultiPeriodDiscriminator, SynthesizerTrn
|
||||
from text.symbols import symbols
|
||||
from tools.log import logger
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
torch.backends.cuda.matmul.allow_tf32 = True
|
||||
torch.backends.cudnn.allow_tf32 = (
|
||||
@@ -427,7 +427,7 @@ def train_and_evaluate(
|
||||
ja_bert,
|
||||
en_bert,
|
||||
style_vec,
|
||||
) in enumerate(tqdm(train_loader, file=sys.stdout)):
|
||||
) in enumerate(tqdm(train_loader, file=get_stdout())):
|
||||
if net_g.module.use_noise_scaled_mas:
|
||||
current_mas_noise_scale = (
|
||||
net_g.module.mas_noise_scale_initial
|
||||
|
||||
@@ -5,6 +5,8 @@ import sys
|
||||
from faster_whisper import WhisperModel
|
||||
from tqdm import tqdm
|
||||
|
||||
from tools.stdout_wrapper import get_stdout
|
||||
|
||||
|
||||
def transcribe(wav_path, initial_prompt=None):
|
||||
segments, _ = model.transcribe(
|
||||
@@ -45,7 +47,7 @@ if __name__ == "__main__":
|
||||
os.rename(output_file, output_file + ".bak")
|
||||
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
for wav_file in tqdm(wav_files, file=sys.stdout):
|
||||
for wav_file in tqdm(wav_files, file=get_stdout()):
|
||||
file_name = os.path.basename(wav_file)
|
||||
text = transcribe(wav_file, initial_prompt=initial_prompt)
|
||||
f.write(f"{file_name}|{speaker_name}|JP|{text}\n")
|
||||
|
||||
Reference in New Issue
Block a user