Skip to content

Commit

Permalink
Merge pull request #165 from deiteris/fixes-2
Browse files Browse the repository at this point in the history
QoL fixes
  • Loading branch information
deiteris authored Aug 6, 2024
2 parents 39e347b + ca29870 commit 270a673
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 70 deletions.
2 changes: 1 addition & 1 deletion client/demo/dist/index.js

Large diffs are not rendered by default.

176 changes: 116 additions & 60 deletions client/demo/src/components/demo/components2/102-3_DeviceArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {
</div>
<div className="config-sub-area-noise-checkbox-container">
<input
className="left-padding-1"
className="left-padding-05"
type="radio"
id="server-device"
name="device-mode"
Expand Down Expand Up @@ -98,7 +98,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1">input</div>
<div className="config-sub-area-control-title left-padding-05">Input</div>
<div className="config-sub-area-control-field">
<select
className="body-select"
Expand Down Expand Up @@ -163,43 +163,71 @@ export const DeviceArea = (_props: DeviceAreaProps) => {
const currentValue = devices.find((x) => {
return (x.hostAPI == inputHostApi || inputHostApi == "ALL") && x.index == serverSetting.serverSetting.serverInputDeviceId;
})
? serverSetting.serverSetting.serverInputDeviceId
: -1;

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1">input</div>
const channelSelector = currentValue?.hostAPI !== 'ASIO'
? <></>
: <div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-05">Ch.</div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-auido-io">
<select
className="config-sub-area-control-field-auido-io-filter"
name="kinds"
id="kinds"
value={inputHostApi}
onChange={(e) => {
setInputHostApi(e.target.value);
}}
>
<option value="ALL" key="ALL">
ALL
</option>
{hostAPIOptions}
</select>
<select
className="config-sub-area-control-field-auido-io-select"
value={currentValue}
className="config-sub-area-control-field-sample-rate-select"
value={serverSetting.serverSetting.asioInputChannel}
onChange={(e) => {
serverSetting.updateServerSettings({ ...serverSetting.serverSetting, serverInputDeviceId: Number(e.target.value) });
serverSetting.updateServerSettings({ ...serverSetting.serverSetting, asioInputChannel: Number(e.target.value) });
}}
>
{filteredDevice}
<option value="-1" key="none">
none
<option key="default" value="-1">
default
</option>
{Array.from(Array(currentValue.maxInputChannels).keys()).map((x) => {
return (
<option key={x} value={x}>
{x}
</option>
);
})}
</select>
</div>
</div>
</div>

return (
<div>
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-05">Input</div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-auido-io">
<select
className="config-sub-area-control-field-auido-io-filter"
name="kinds"
id="kinds"
value={inputHostApi}
onChange={(e) => {
setInputHostApi(e.target.value);
}}
>
<option value="ALL" key="ALL">
ALL
</option>
{hostAPIOptions}
</select>
<select
className="config-sub-area-control-field-auido-io-select"
value={currentValue ? currentValue.index : -1}
onChange={(e) => {
serverSetting.updateServerSettings({ ...serverSetting.serverSetting, serverInputDeviceId: Number(e.target.value) });
}}
>
{filteredDevice}
<option value="-1" key="none">
none
</option>
</select>
</div>
</div>
</div>
{channelSelector}
</div>
);
}, [inputHostApi, serverSetting.serverSetting, serverSetting.updateServerSettings, serverSetting.serverSetting.enableServerAudio]);

Expand Down Expand Up @@ -258,7 +286,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {
return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-wav-file left-padding-1">
<div className="config-sub-area-control-field-wav-file left-padding-05">
<div className="config-sub-area-control-field-wav-file-audio-container">
{/* <audio id={AUDIO_ELEMENT_FOR_TEST_ORIGINAL} controls hidden></audio> */}
<audio className="config-sub-area-control-field-wav-file-audio" id={AUDIO_ELEMENT_FOR_TEST_CONVERTED} controls controlsList="nodownload noplaybackrate"></audio>
Expand Down Expand Up @@ -353,7 +381,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {
const echobackClass = shareScreenEnabled ? "config-sub-area-control-field-screen-select-button-active" : "config-sub-area-control-field-screen-select-button";
return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1"></div>
<div className="config-sub-area-control-title left-padding-05"></div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-screen-select">
<div
Expand Down Expand Up @@ -442,7 +470,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1">output</div>
<div className="config-sub-area-control-title left-padding-05">Output</div>
<div className="config-sub-area-control-field">
<select
className="body-select"
Expand Down Expand Up @@ -505,43 +533,71 @@ export const DeviceArea = (_props: DeviceAreaProps) => {
const currentValue = devices.find((x) => {
return (x.hostAPI == outputHostApi || outputHostApi == "ALL") && x.index == serverSetting.serverSetting.serverOutputDeviceId;
})
? serverSetting.serverSetting.serverOutputDeviceId
: -1;

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1">output</div>
const channelSelector = currentValue?.hostAPI !== 'ASIO'
? <></>
: <div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-05">Ch.</div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-auido-io">
<select
className="config-sub-area-control-field-auido-io-filter"
name="kinds"
id="kinds"
value={outputHostApi}
onChange={(e) => {
setOutputHostApi(e.target.value);
}}
>
<option value="ALL" key="ALL">
ALL
</option>
{hostAPIOptions}
</select>
<select
className="config-sub-area-control-field-auido-io-select"
value={currentValue}
className="config-sub-area-control-field-sample-rate-select"
value={serverSetting.serverSetting.asioOutputChannel}
onChange={(e) => {
serverSetting.updateServerSettings({ ...serverSetting.serverSetting, serverOutputDeviceId: Number(e.target.value) });
serverSetting.updateServerSettings({ ...serverSetting.serverSetting, asioOutputChannel: Number(e.target.value) });
}}
>
{filteredDevice}
<option value="-1" key="none">
none
<option key="default" value="-1">
default
</option>
{Array.from(Array(currentValue.maxOutputChannels).keys()).map((x) => {
return (
<option key={x} value={x}>
{x}
</option>
);
})}
</select>
</div>
</div>
</div>

return (
<div>
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-05">Output</div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-auido-io">
<select
className="config-sub-area-control-field-auido-io-filter"
name="kinds"
id="kinds"
value={outputHostApi}
onChange={(e) => {
setOutputHostApi(e.target.value);
}}
>
<option value="ALL" key="ALL">
ALL
</option>
{hostAPIOptions}
</select>
<select
className="config-sub-area-control-field-auido-io-select"
value={currentValue ? currentValue.index : -1}
onChange={(e) => {
serverSetting.updateServerSettings({ ...serverSetting.serverSetting, serverOutputDeviceId: Number(e.target.value) });
}}
>
{filteredDevice}
<option value="-1" key="none">
none
</option>
</select>
</div>
</div>
</div>
{channelSelector}
</div>
);
}, [outputHostApi, serverSetting.serverSetting, serverSetting.updateServerSettings, serverSetting.serverSetting.enableServerAudio]);

Expand Down Expand Up @@ -587,7 +643,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1"><a className="hint-text" data-tooltip-id="hint" data-tooltip-content="Sample rate of audio devices.">S.R.</a></div>
<div className="config-sub-area-control-title left-padding-05"><a className="hint-text" data-tooltip-id="hint" data-tooltip-content="Sample rate of audio devices.">S.R.</a></div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-auido-io">
<select
Expand Down Expand Up @@ -673,7 +729,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1">monitor</div>
<div className="config-sub-area-control-title left-padding-05">Monitor</div>
<div className="config-sub-area-control-field">
<select
className="body-select"
Expand Down Expand Up @@ -746,7 +802,7 @@ export const DeviceArea = (_props: DeviceAreaProps) => {

return (
<div className="config-sub-area-control">
<div className="config-sub-area-control-title left-padding-1">monitor</div>
<div className="config-sub-area-control-title left-padding-05">Monitor</div>
<div className="config-sub-area-control-field">
<div className="config-sub-area-control-field-auido-io">
<select
Expand Down
10 changes: 9 additions & 1 deletion client/lib/src/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export const ServerSettingKey = {
serverInputAudioGain: "serverInputAudioGain",
serverOutputAudioGain: "serverOutputAudioGain",
serverMonitorAudioGain: "serverMonitorAudioGain",
asioInputChannel: "asioInputChannel",
asioOutputChannel: "asioOutputChannel",

tran: "tran",
formantShift: "formantShift",
Expand Down Expand Up @@ -132,6 +134,8 @@ export type VoiceChangerServerSetting = {
serverInputAudioGain: number;
serverOutputAudioGain: number;
serverMonitorAudioGain: number;
asioInputChannel: number;
asioOutputChannel: number;

tran: number;
formantShift: number;
Expand Down Expand Up @@ -178,10 +182,12 @@ export type RVCModelSlot = ModelSlot & {
export type ModelSlotUnion = RVCModelSlot;

type ServerAudioDevice = {
kind: "audioinput" | "audiooutput";
index: number;
name: string;
hostAPI: string;
maxInputChannels: number;
maxOutputChannels: number;
default_samplerate: number;
};

export type ServerInfo = VoiceChangerServerSetting & {
Expand Down Expand Up @@ -247,6 +253,8 @@ export const DefaultServerSetting: ServerInfo = {
serverInputAudioGain: 1.0,
serverOutputAudioGain: 1.0,
serverMonitorAudioGain: 1.0,
asioInputChannel: -1,
asioOutputChannel: -1,

// VC Specific
srcId: 0,
Expand Down
5 changes: 1 addition & 4 deletions server/voice_changer/Local/AudioDeviceList.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@

@dataclass
class ServerAudioDevice:
kind: ServerAudioDeviceType = "audioinput"
index: int = 0
name: str = ""
hostAPI: str = ""
maxInputChannels: int = 0
maxOutputChannels: int = 0
default_samplerate: int = 0
available_samplerates: list[int] = field(default_factory=lambda: [])
# available_samplerates: list[int] = field(default_factory=lambda: [])


def dummy_callback(data: np.ndarray, frames, times, status):
Expand Down Expand Up @@ -71,7 +70,6 @@ def list_audio_device():
serverAudioOutputDevices: list[ServerAudioDevice] = []
for d in inputAudioDeviceList:
serverInputAudioDevice: ServerAudioDevice = ServerAudioDevice(
kind="audioinput",
index=d["index"],
name=d["name"],
hostAPI=hostapis[d["hostapi"]]["name"],
Expand All @@ -82,7 +80,6 @@ def list_audio_device():
serverAudioInputDevices.append(serverInputAudioDevice)
for d in outputAudioDeviceList:
serverOutputAudioDevice: ServerAudioDevice = ServerAudioDevice(
kind="audiooutput",
index=d["index"],
name=d["name"],
hostAPI=hostapis[d["hostapi"]]["name"],
Expand Down
9 changes: 7 additions & 2 deletions server/voice_changer/Local/ServerDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,16 @@ def start(self):

# Generate ExtraSetting
inputExtraSetting = None
outputExtraSetting = None
if serverInputAudioDevice and "WASAPI" in serverInputAudioDevice.hostAPI:
inputExtraSetting = sd.WasapiSettings(exclusive=bool(self.settings.exclusiveMode))
elif serverInputAudioDevice and "ASIO" in serverInputAudioDevice.hostAPI and self.settings.asioInputChannel != -1:
inputExtraSetting = sd.AsioSettings(channel_selectors=[self.settings.asioInputChannel])

outputExtraSetting = None
if serverOutputAudioDevice and "WASAPI" in serverOutputAudioDevice.hostAPI:
outputExtraSetting = sd.WasapiSettings(exclusive=bool(self.settings.exclusiveMode))
elif serverInputAudioDevice and "ASIO" in serverInputAudioDevice.hostAPI and self.settings.asioOutputChannel != -1:
outputExtraSetting = sd.AsioSettings(channel_selectors=[self.settings.asioOutputChannel])

monitorExtraSetting = None
if serverMonitorAudioDevice and "WASAPI" in serverMonitorAudioDevice.hostAPI:
Expand Down Expand Up @@ -242,6 +247,6 @@ def update_settings(self, key: str, val, old_val):
if key == 'serverAudioStated':
# Toggle control loop
self.control_loop = val
if key in { 'serverAudioStated', 'serverInputDeviceId', 'serverOutputDeviceId', 'serverMonitorDeviceId', 'serverReadChunkSize', 'serverAudioSampleRate' }:
if key in { 'serverAudioStated', 'serverInputDeviceId', 'serverOutputDeviceId', 'serverMonitorDeviceId', 'serverReadChunkSize', 'serverAudioSampleRate', 'asioInputChannel', 'asioOutputChannel' }:
# Break stream loop to reconfigure or turn server audio off
self.stream_loop = False
2 changes: 1 addition & 1 deletion server/voice_changer/RVC/modelMerger/MergeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def load_weight(path: str):
merged["params"] = state_dict["params"] if "params" in state_dict else None
merged["version"] = state_dict["version"] if "version" in state_dict else None
merged["sr"] = state_dict["sr"]
merged["f0"] = int(state_dict["f0"])
merged["f0"] = int(state_dict["f0"] == "1" or state_dict["f0"] == "True")
try:
# Some forks do not include info apparently (?)
merged["info"] = state_dict["info"]
Expand Down
Loading

0 comments on commit 270a673

Please sign in to comment.