bugfix: timer update

This commit is contained in:
w-okada 2023-11-14 05:39:07 +09:00
parent 85dfaff25f
commit 958b03bd5a
5 changed files with 22 additions and 15 deletions

View File

@ -22,7 +22,7 @@
"name": "configArea", "name": "configArea",
"options": { "options": {
"detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx"], "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx"],
"inputChunkNums": [1, 2, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384] "inputChunkNums": [1, 2, 4, 6, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384]
} }
} }
] ]

View File

@ -22,7 +22,7 @@
"name": "configArea", "name": "configArea",
"options": { "options": {
"detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx"], "detectors": ["dio", "harvest", "crepe", "crepe_full", "crepe_tiny", "rmvpe", "rmvpe_onnx"],
"inputChunkNums": [1, 2, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384] "inputChunkNums": [1, 2, 4, 6, 8, 16, 24, 32, 40, 48, 64, 80, 96, 112, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 2048, 4096, 8192, 16384]
} }
} }
] ]

View File

@ -11,7 +11,7 @@ from mods.log_control import VoiceChangaerLogger
from voice_changer.IORecorder import IORecorder from voice_changer.IORecorder import IORecorder
from voice_changer.utils.Timer import Timer from voice_changer.utils.Timer import Timer2
from voice_changer.utils.VoiceChangerIF import VoiceChangerIF from voice_changer.utils.VoiceChangerIF import VoiceChangerIF
from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel
from Exceptions import ( from Exceptions import (
@ -191,7 +191,7 @@ class VoiceChanger(VoiceChangerIF):
processing_sampling_rate = self.voiceChanger.get_processing_sampling_rate() processing_sampling_rate = self.voiceChanger.get_processing_sampling_rate()
# 前処理 # 前処理
with Timer("pre-process") as t: with Timer2("pre-process", False) as t:
if self.settings.inputSampleRate != processing_sampling_rate: if self.settings.inputSampleRate != processing_sampling_rate:
newData = cast( newData = cast(
AudioInOut, AudioInOut,
@ -211,10 +211,11 @@ class VoiceChanger(VoiceChangerIF):
self._generate_strength(crossfade_frame) self._generate_strength(crossfade_frame)
data = self.voiceChanger.generate_input(newData, block_frame, crossfade_frame, sola_search_frame) data = self.voiceChanger.generate_input(newData, block_frame, crossfade_frame, sola_search_frame)
t.record("fin")
preprocess_time = t.secs preprocess_time = t.secs
# 変換処理 # 変換処理
with Timer("main-process") as t: with Timer2("main-process", False) as t:
# Inference # Inference
audio = self.voiceChanger.inference(data) audio = self.voiceChanger.inference(data)
@ -256,10 +257,11 @@ class VoiceChanger(VoiceChangerIF):
else: else:
self.sola_buffer = audio[-crossfade_frame:] * self.np_prev_strength self.sola_buffer = audio[-crossfade_frame:] * self.np_prev_strength
# self.sola_buffer = audio[- crossfade_frame:] # self.sola_buffer = audio[- crossfade_frame:]
t.record("fin")
mainprocess_time = t.secs mainprocess_time = t.secs
# 後処理 # 後処理
with Timer("post-process") as t: with Timer2("post-process", False) as t:
result = result.astype(np.int16) result = result.astype(np.int16)
if self.settings.outputSampleRate != processing_sampling_rate: if self.settings.outputSampleRate != processing_sampling_rate:
@ -293,6 +295,7 @@ class VoiceChanger(VoiceChangerIF):
if self.settings.recordIO == 1: if self.settings.recordIO == 1:
self.ioRecorder.writeInput(receivedData) self.ioRecorder.writeInput(receivedData)
self.ioRecorder.writeOutput(outputData.tobytes()) self.ioRecorder.writeOutput(outputData.tobytes())
t.record("fin")
postprocess_time = t.secs postprocess_time = t.secs

View File

@ -23,7 +23,7 @@ from mods.log_control import VoiceChangaerLogger
from voice_changer.IORecorder import IORecorder from voice_changer.IORecorder import IORecorder
from voice_changer.utils.Timer import Timer from voice_changer.utils.Timer import Timer2
from voice_changer.utils.VoiceChangerIF import VoiceChangerIF from voice_changer.utils.VoiceChangerIF import VoiceChangerIF
from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel from voice_changer.utils.VoiceChangerModel import AudioInOut, VoiceChangerModel
from Exceptions import ( from Exceptions import (
@ -146,6 +146,7 @@ class VoiceChangerV2(VoiceChangerIF):
self.settings.outputSampleRate, self.settings.outputSampleRate,
# 16000, # 16000,
) )
print(f"-------------------------- - - - {self.settings.inputSampleRate}, {self.settings.outputSampleRate}")
if key == "recordIO" and val == 0: if key == "recordIO" and val == 0:
if hasattr(self, "ioRecorder"): if hasattr(self, "ioRecorder"):
self.ioRecorder.close() self.ioRecorder.close()
@ -216,7 +217,7 @@ class VoiceChangerV2(VoiceChangerIF):
if self.voiceChanger is None: if self.voiceChanger is None:
raise VoiceChangerIsNotSelectedException("Voice Changer is not selected.") raise VoiceChangerIsNotSelectedException("Voice Changer is not selected.")
with Timer("main-process") as t: with Timer2("main-process", False) as t:
processing_sampling_rate = self.voiceChanger.get_processing_sampling_rate() processing_sampling_rate = self.voiceChanger.get_processing_sampling_rate()
if self.noCrossFade: # Beatrice, LLVC if self.noCrossFade: # Beatrice, LLVC
@ -282,7 +283,7 @@ class VoiceChangerV2(VoiceChangerIF):
mainprocess_time = t.secs mainprocess_time = t.secs
# 後処理 # 後処理
with Timer("post-process") as t: with Timer2("post-process", False) as t:
result = result.astype(np.int16) result = result.astype(np.int16)
print_convert_processing(f" Output data size of {result.shape[0]}/{processing_sampling_rate}hz {result .shape[0]}/{self.settings.outputSampleRate}hz") print_convert_processing(f" Output data size of {result.shape[0]}/{processing_sampling_rate}hz {result .shape[0]}/{self.settings.outputSampleRate}hz")
@ -299,6 +300,9 @@ class VoiceChangerV2(VoiceChangerIF):
outputData = result outputData = result
if self.settings.recordIO == 1: if self.settings.recordIO == 1:
print(f"-------------------------- - - -shapes::: {receivedData.shape}, {outputData.shape}")
print(f"-------------------------- - - -shapes::: {receivedData.dtype}, {outputData.dtype}")
print(f"-------------------------- - - -shapes::: {receivedData[0:10]}, {outputData[0:10]}")
self.ioRecorder.writeInput(receivedData) self.ioRecorder.writeInput(receivedData)
self.ioRecorder.writeOutput(outputData.tobytes()) self.ioRecorder.writeOutput(outputData.tobytes())

View File

@ -1,9 +1,10 @@
import time import time
import inspect import inspect
from typing import Dict, List
class Timer(object): class Timer(object):
storedSecs = {} # Class variable storedSecs: Dict[str, Dict[str, List[float]]] = {} # Class variable
def __init__(self, title: str, enalbe: bool = True): def __init__(self, title: str, enalbe: bool = True):
self.title = title self.title = title
@ -24,7 +25,7 @@ class Timer(object):
line_number = frame.lineno line_number = frame.lineno
self.key = f"{title}_{filename}_{line_number}" self.key = f"{title}_{filename}_{line_number}"
if self.key not in self.storedSecs: if self.key not in self.storedSecs:
self.storedSecs[self.key] = [] self.storedSecs[self.key] = {}
def __enter__(self): def __enter__(self):
if self.enable is False: if self.enable is False:
@ -44,7 +45,7 @@ class Timer(object):
class Timer2(object): class Timer2(object):
storedSecs = {} # Class variable storedSecs: Dict[str, Dict[str, List[float]]] = {} # Class variable
def __init__(self, title: str, enalbe: bool = True): def __init__(self, title: str, enalbe: bool = True):
self.title = title self.title = title
@ -93,4 +94,3 @@ class Timer2(object):
section = key.split("_")[-1] section = key.split("_")[-1]
milisecAvr = sum(val) / len(val) * 1000 milisecAvr = sum(val) / len(val) * 1000
print(f"{section}: {milisecAvr} msec") print(f"{section}: {milisecAvr} msec")