-bugfix: server device mode sampling rate restore

-bugfix: server device mode data type
This commit is contained in:
w-okada 2023-06-29 05:50:32 +09:00
parent b5e3f11beb
commit f0cdb45f32
4 changed files with 10 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -47,7 +47,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {
</div> </div>
</div> </div>
) )
}, [serverSetting.serverSetting, serverSetting.updateServerSettings]) }, [serverSetting.serverSetting, serverSetting.updateServerSettings, isConverting])

View File

@ -82,9 +82,10 @@ class ServerDevice:
indata = indata * self.settings.serverInputAudioGain indata = indata * self.settings.serverInputAudioGain
with Timer("all_inference_time") as t: with Timer("all_inference_time") as t:
unpackedData = librosa.to_mono(indata.T) * 32768.0 unpackedData = librosa.to_mono(indata.T) * 32768.0
unpackedData = unpackedData.astype(np.int16)
out_wav, times = self.serverDeviceCallbacks.on_request(unpackedData) out_wav, times = self.serverDeviceCallbacks.on_request(unpackedData)
outputChunnels = outdata.shape[1] outputChannels = outdata.shape[1]
outdata[:] = np.repeat(out_wav, outputChunnels).reshape(-1, outputChunnels) / 32768.0 outdata[:] = np.repeat(out_wav, outputChannels).reshape(-1, outputChannels) / 32768.0
outdata[:] = outdata * self.settings.serverOutputAudioGain outdata[:] = outdata * self.settings.serverOutputAudioGain
all_inference_time = t.secs all_inference_time = t.secs
self.performance = [all_inference_time] + times self.performance = [all_inference_time] + times
@ -100,7 +101,6 @@ class ServerDevice:
currentModelSamplingRate = -1 currentModelSamplingRate = -1
while True: while True:
if self.settings.serverAudioStated == 0 or self.settings.serverInputDeviceId == -1: if self.settings.serverAudioStated == 0 or self.settings.serverInputDeviceId == -1:
# self.settings.inputSampleRate = 48000
time.sleep(2) time.sleep(2)
else: else:
sd._terminate() sd._terminate()
@ -135,6 +135,7 @@ class ServerDevice:
blocksize=block_frame, blocksize=block_frame,
# samplerate=currentModelSamplingRate, # samplerate=currentModelSamplingRate,
dtype="float32", dtype="float32",
# dtype="int16",
# channels=[currentInputChannelNum, currentOutputChannelNum], # channels=[currentInputChannelNum, currentOutputChannelNum],
): ):
pass pass
@ -156,6 +157,7 @@ class ServerDevice:
# blocksize=block_frame, # blocksize=block_frame,
# samplerate=vc.settings.serverInputAudioSampleRate, # samplerate=vc.settings.serverInputAudioSampleRate,
dtype="float32", dtype="float32",
# dtype="int16",
# channels=[currentInputChannelNum, currentOutputChannelNum], # channels=[currentInputChannelNum, currentOutputChannelNum],
): ):
while self.settings.serverAudioStated == 1 and sd.default.device[0] == self.settings.serverInputDeviceId and sd.default.device[1] == self.settings.serverOutputDeviceId and currentModelSamplingRate == self.serverDeviceCallbacks.get_processing_sampling_rate() and currentInputChunkNum == self.settings.serverReadChunkSize: while self.settings.serverAudioStated == 1 and sd.default.device[0] == self.settings.serverInputDeviceId and sd.default.device[1] == self.settings.serverOutputDeviceId and currentModelSamplingRate == self.serverDeviceCallbacks.get_processing_sampling_rate() and currentInputChunkNum == self.settings.serverReadChunkSize:

View File

@ -113,6 +113,9 @@ class VoiceChanger:
print("[Voice Changer] Voice Changer is not selected.") print("[Voice Changer] Voice Changer is not selected.")
return self.get_info() return self.get_info()
if key == "serverAudioStated" and val == 0:
self.settings.inputSampleRate = 48000
if key in self.settings.intData: if key in self.settings.intData:
setattr(self.settings, key, int(val)) setattr(self.settings, key, int(val))
if key == "crossFadeOffsetRate" or key == "crossFadeEndRate": if key == "crossFadeOffsetRate" or key == "crossFadeEndRate":