Skip to content

Commit

Permalink
-bugfix: server device mode sampling rate restore
Browse files Browse the repository at this point in the history
-bugfix: server device mode data type
  • Loading branch information
w-okada committed Jun 28, 2023
1 parent b5e3f11 commit f0cdb45
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/demo/dist/index.js

Large diffs are not rendered by default.

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



8 changes: 5 additions & 3 deletions server/voice_changer/Local/ServerDevice.py
Original file line number Diff line number Diff line change
@@ -82,9 +82,10 @@ def audio_callback(self, indata: np.ndarray, outdata: np.ndarray, frames, times,
indata = indata * self.settings.serverInputAudioGain
with Timer("all_inference_time") as t:
unpackedData = librosa.to_mono(indata.T) * 32768.0
unpackedData = unpackedData.astype(np.int16)
out_wav, times = self.serverDeviceCallbacks.on_request(unpackedData)
outputChunnels = outdata.shape[1]
outdata[:] = np.repeat(out_wav, outputChunnels).reshape(-1, outputChunnels) / 32768.0
outputChannels = outdata.shape[1]
outdata[:] = np.repeat(out_wav, outputChannels).reshape(-1, outputChannels) / 32768.0
outdata[:] = outdata * self.settings.serverOutputAudioGain
all_inference_time = t.secs
self.performance = [all_inference_time] + times
@@ -100,7 +101,6 @@ def start(self):
currentModelSamplingRate = -1
while True:
if self.settings.serverAudioStated == 0 or self.settings.serverInputDeviceId == -1:
# self.settings.inputSampleRate = 48000
time.sleep(2)
else:
sd._terminate()
@@ -135,6 +135,7 @@ def start(self):
blocksize=block_frame,
# samplerate=currentModelSamplingRate,
dtype="float32",
# dtype="int16",
# channels=[currentInputChannelNum, currentOutputChannelNum],
):
pass
@@ -156,6 +157,7 @@ def start(self):
# blocksize=block_frame,
# samplerate=vc.settings.serverInputAudioSampleRate,
dtype="float32",
# dtype="int16",
# 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:
3 changes: 3 additions & 0 deletions server/voice_changer/VoiceChanger.py
Original file line number Diff line number Diff line change
@@ -113,6 +113,9 @@ def update_settings(self, key: str, val: Any):
print("[Voice Changer] Voice Changer is not selected.")
return self.get_info()

if key == "serverAudioStated" and val == 0:
self.settings.inputSampleRate = 48000

if key in self.settings.intData:
setattr(self.settings, key, int(val))
if key == "crossFadeOffsetRate" or key == "crossFadeEndRate":

0 comments on commit f0cdb45

Please sign in to comment.