mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 21:45:00 +03:00
bugfix: multi-processing trial gabage. looping instanciate voice changer..
This commit is contained in:
parent
1278094ccd
commit
9a1a9245c8
@ -4,29 +4,12 @@ import numpy as np
|
|||||||
import socketio
|
import socketio
|
||||||
from voice_changer.VoiceChangerManager import VoiceChangerManager
|
from voice_changer.VoiceChangerManager import VoiceChangerManager
|
||||||
|
|
||||||
import time
|
|
||||||
import multiprocessing as mp
|
|
||||||
|
|
||||||
|
|
||||||
# Queueからデータを読み取り
|
|
||||||
def read(q_in, q_out):
|
|
||||||
while True:
|
|
||||||
time.sleep(1)
|
|
||||||
[timestamp, sid] = q_in.get(True)
|
|
||||||
print("put........................................")
|
|
||||||
q_out.put([timestamp, sid])
|
|
||||||
|
|
||||||
|
|
||||||
class MMVC_Namespace(socketio.AsyncNamespace):
|
class MMVC_Namespace(socketio.AsyncNamespace):
|
||||||
def __init__(self, namespace: str, voiceChangerManager: VoiceChangerManager):
|
def __init__(self, namespace: str, voiceChangerManager: VoiceChangerManager):
|
||||||
super().__init__(namespace)
|
super().__init__(namespace)
|
||||||
self.voiceChangerManager = voiceChangerManager
|
self.voiceChangerManager = voiceChangerManager
|
||||||
|
|
||||||
self.q_in = mp.Queue()
|
|
||||||
self.q_out = mp.Queue()
|
|
||||||
self.p = mp.Process(target=read, args=(self.q_in, self.q_out))
|
|
||||||
self.p.start()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_instance(cls, voiceChangerManager: VoiceChangerManager):
|
def get_instance(cls, voiceChangerManager: VoiceChangerManager):
|
||||||
if not hasattr(cls, "_instance"):
|
if not hasattr(cls, "_instance"):
|
||||||
@ -45,19 +28,6 @@ class MMVC_Namespace(socketio.AsyncNamespace):
|
|||||||
print(data)
|
print(data)
|
||||||
await self.emit('response', [timestamp, 0], to=sid)
|
await self.emit('response', [timestamp, 0], to=sid)
|
||||||
else:
|
else:
|
||||||
# print("receive ")
|
|
||||||
# self.q_in.put([timestamp, sid])
|
|
||||||
# while self.q_out.empty() == False:
|
|
||||||
# print("send........................................")
|
|
||||||
# [timestamp, sid] = self.q_out.get(True)
|
|
||||||
# await self.emit('response', [timestamp, 0], to=sid)
|
|
||||||
# print("end")
|
|
||||||
|
|
||||||
# print("receive ")
|
|
||||||
# time.sleep(2)
|
|
||||||
# await self.emit('response', [timestamp, 0], to=sid)
|
|
||||||
# print("end")
|
|
||||||
|
|
||||||
unpackedData = np.array(struct.unpack('<%sh' % (len(data) // struct.calcsize('<h')), data))
|
unpackedData = np.array(struct.unpack('<%sh' % (len(data) // struct.calcsize('<h')), data))
|
||||||
audio1, perf = self.voiceChangerManager.changeVoice(unpackedData)
|
audio1, perf = self.voiceChangerManager.changeVoice(unpackedData)
|
||||||
bin = struct.pack('<%sh' % len(audio1), *audio1)
|
bin = struct.pack('<%sh' % len(audio1), *audio1)
|
||||||
|
@ -15,7 +15,6 @@ import pyworld as pw
|
|||||||
from voice_changer.client_modules import convert_continuos_f0, spectrogram_torch, TextAudioSpeakerCollate, get_hparams_from_file, load_checkpoint
|
from voice_changer.client_modules import convert_continuos_f0, spectrogram_torch, TextAudioSpeakerCollate, get_hparams_from_file, load_checkpoint
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import multiprocessing as mp
|
|
||||||
|
|
||||||
providers = ['OpenVINOExecutionProvider', "CUDAExecutionProvider", "DmlExecutionProvider", "CPUExecutionProvider"]
|
providers = ['OpenVINOExecutionProvider', "CUDAExecutionProvider", "DmlExecutionProvider", "CPUExecutionProvider"]
|
||||||
|
|
||||||
@ -487,7 +486,6 @@ class VoiceChanger():
|
|||||||
|
|
||||||
with Timer("pre-process") as t:
|
with Timer("pre-process") as t:
|
||||||
if self.settings.inputSampleRate != 24000:
|
if self.settings.inputSampleRate != 24000:
|
||||||
# print("convert sampling rate!", self.settings.inputSampleRate)
|
|
||||||
unpackedData = resampy.resample(unpackedData, 48000, 24000)
|
unpackedData = resampy.resample(unpackedData, 48000, 24000)
|
||||||
convertSize = unpackedData.shape[0] + min(self.settings.crossFadeOverlapSize, unpackedData.shape[0])
|
convertSize = unpackedData.shape[0] + min(self.settings.crossFadeOverlapSize, unpackedData.shape[0])
|
||||||
# print(convertSize, unpackedData.shape[0])
|
# print(convertSize, unpackedData.shape[0])
|
||||||
|
Loading…
Reference in New Issue
Block a user