mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 21:45:00 +03:00
add minimum convert size
This commit is contained in:
parent
a993f4eefd
commit
61cb0a416e
@ -1,4 +1,4 @@
|
|||||||
import { OnnxExecutionProvider, Protocol, Framework, fileSelector } from "@dannadori/voice-changer-client-js"
|
import { OnnxExecutionProvider, Framework, fileSelector } from "@dannadori/voice-changer-client-js"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { ClientState } from "./hooks/useClient"
|
import { ClientState } from "./hooks/useClient"
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { BufferSize } from "@dannadori/voice-changer-client-js"
|
import React, { useMemo } from "react"
|
||||||
import React, { useMemo, useState } from "react"
|
|
||||||
import { ClientState } from "./hooks/useClient"
|
import { ClientState } from "./hooks/useClient"
|
||||||
|
|
||||||
export type UseConvertSettingProps = {
|
export type UseConvertSettingProps = {
|
||||||
|
@ -108,6 +108,20 @@ export const useAdvancedSetting = (props: UseAdvancedSettingProps): AdvancedSett
|
|||||||
)
|
)
|
||||||
}, [props.clientState.serverSetting.setting.convertChunkNum, props.clientState.serverSetting.setConvertChunkNum])
|
}, [props.clientState.serverSetting.setting.convertChunkNum, props.clientState.serverSetting.setConvertChunkNum])
|
||||||
|
|
||||||
|
const minConvertSizeRow = useMemo(() => {
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div className="body-row split-3-7 left-padding-1 guided">
|
||||||
|
<div className="body-item-title left-padding-1">Min Convert Size(byte)</div>
|
||||||
|
<div className="body-input-container">
|
||||||
|
<input type="number" min={0} max={8196} step={8196} value={props.clientState.serverSetting.setting.minConvertSize} onChange={(e) => {
|
||||||
|
props.clientState.serverSetting.setMinConvertSize(Number(e.target.value))
|
||||||
|
}} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}, [props.clientState.serverSetting.setting.minConvertSize, props.clientState.serverSetting.setMinConvertSize])
|
||||||
|
|
||||||
const crossFadeOverlapRateRow = useMemo(() => {
|
const crossFadeOverlapRateRow = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<div className="body-row split-3-7 left-padding-1 guided">
|
<div className="body-row split-3-7 left-padding-1 guided">
|
||||||
@ -240,6 +254,7 @@ export const useAdvancedSetting = (props: UseAdvancedSettingProps): AdvancedSett
|
|||||||
<div className="body-row divider"></div>
|
<div className="body-row divider"></div>
|
||||||
|
|
||||||
{convertChunkNumRow}
|
{convertChunkNumRow}
|
||||||
|
{minConvertSizeRow}
|
||||||
{crossFadeOverlapRateRow}
|
{crossFadeOverlapRateRow}
|
||||||
{crossFadeOffsetRateRow}
|
{crossFadeOffsetRateRow}
|
||||||
{crossFadeEndRateRow}
|
{crossFadeEndRateRow}
|
||||||
@ -251,7 +266,7 @@ export const useAdvancedSetting = (props: UseAdvancedSettingProps): AdvancedSett
|
|||||||
<div className="body-row divider"></div>
|
<div className="body-row divider"></div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}, [showAdvancedSetting, mmvcServerUrlRow, protocolRow, sampleRateRow, bufferSizeRow, convertChunkNumRow, crossFadeOverlapRateRow, crossFadeOffsetRateRow, crossFadeEndRateRow, vfForceDisableRow, voiceChangeModeRow, workletSettingRow])
|
}, [showAdvancedSetting, mmvcServerUrlRow, protocolRow, sampleRateRow, bufferSizeRow, convertChunkNumRow, minConvertSizeRow, crossFadeOverlapRateRow, crossFadeOffsetRateRow, crossFadeEndRateRow, vfForceDisableRow, voiceChangeModeRow, workletSettingRow])
|
||||||
|
|
||||||
|
|
||||||
const advancedSetting = useMemo(() => {
|
const advancedSetting = useMemo(() => {
|
||||||
|
@ -25,6 +25,7 @@ export type ServerSettingState = {
|
|||||||
setSrcId: (num: number) => Promise<boolean>;
|
setSrcId: (num: number) => Promise<boolean>;
|
||||||
setDstId: (num: number) => Promise<boolean>;
|
setDstId: (num: number) => Promise<boolean>;
|
||||||
setConvertChunkNum: (num: number) => Promise<boolean>;
|
setConvertChunkNum: (num: number) => Promise<boolean>;
|
||||||
|
setMinConvertSize: (num: number) => Promise<boolean>
|
||||||
setGpu: (num: number) => Promise<boolean>;
|
setGpu: (num: number) => Promise<boolean>;
|
||||||
setCrossFadeOffsetRate: (num: number) => Promise<boolean>;
|
setCrossFadeOffsetRate: (num: number) => Promise<boolean>;
|
||||||
setCrossFadeEndRate: (num: number) => Promise<boolean>;
|
setCrossFadeEndRate: (num: number) => Promise<boolean>;
|
||||||
@ -56,6 +57,7 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
_setSetting({
|
_setSetting({
|
||||||
...settingRef.current,
|
...settingRef.current,
|
||||||
convertChunkNum: res.convertChunkNum,
|
convertChunkNum: res.convertChunkNum,
|
||||||
|
minConvertSize: res.minConvertSize,
|
||||||
srcId: res.srcId,
|
srcId: res.srcId,
|
||||||
dstId: res.dstId,
|
dstId: res.dstId,
|
||||||
gpu: res.gpu,
|
gpu: res.gpu,
|
||||||
@ -103,6 +105,13 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
}
|
}
|
||||||
}, [props.voiceChangerClient])
|
}, [props.voiceChangerClient])
|
||||||
|
|
||||||
|
const setMinConvertSize = useMemo(() => {
|
||||||
|
return async (num: number) => {
|
||||||
|
return await _set_and_store(ServerSettingKey.minConvertSize, "" + num)
|
||||||
|
}
|
||||||
|
}, [props.voiceChangerClient])
|
||||||
|
|
||||||
|
|
||||||
const setGpu = useMemo(() => {
|
const setGpu = useMemo(() => {
|
||||||
return async (num: number) => {
|
return async (num: number) => {
|
||||||
return await _set_and_store(ServerSettingKey.gpu, "" + num)
|
return await _set_and_store(ServerSettingKey.gpu, "" + num)
|
||||||
@ -125,6 +134,8 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
}
|
}
|
||||||
}, [props.voiceChangerClient])
|
}, [props.voiceChangerClient])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////
|
//////////////
|
||||||
// 操作
|
// 操作
|
||||||
/////////////
|
/////////////
|
||||||
@ -218,6 +229,7 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
|||||||
setSrcId,
|
setSrcId,
|
||||||
setDstId,
|
setDstId,
|
||||||
setConvertChunkNum,
|
setConvertChunkNum,
|
||||||
|
setMinConvertSize,
|
||||||
setGpu,
|
setGpu,
|
||||||
setCrossFadeOffsetRate,
|
setCrossFadeOffsetRate,
|
||||||
setCrossFadeEndRate,
|
setCrossFadeEndRate,
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
// types
|
// types
|
||||||
export type VoiceChangerServerSetting = {
|
export type VoiceChangerServerSetting = {
|
||||||
convertChunkNum: number, // VITSに入力する変換サイズ。(入力データの2倍以上の大きさで指定。それより小さいものが指定された場合は、サーバ側で自動的に入力の2倍のサイズが設定される。)
|
convertChunkNum: number, // VITSに入力する変換サイズ。(入力データの2倍以上の大きさで指定。それより小さいものが指定された場合は、サーバ側で自動的に入力の2倍のサイズが設定される。)
|
||||||
|
minConvertSize: number, // この値より小さい場合にこの値に揃える。
|
||||||
|
|
||||||
srcId: number,
|
srcId: number,
|
||||||
dstId: number,
|
dstId: number,
|
||||||
gpu: number,
|
gpu: number,
|
||||||
@ -50,6 +52,7 @@ export type ServerInfo = {
|
|||||||
pyTorchModelFile: string,
|
pyTorchModelFile: string,
|
||||||
onnxModelFile: string,
|
onnxModelFile: string,
|
||||||
convertChunkNum: number,
|
convertChunkNum: number,
|
||||||
|
minConvertSize: number,
|
||||||
crossFadeOffsetRate: number,
|
crossFadeOffsetRate: number,
|
||||||
crossFadeEndRate: number,
|
crossFadeEndRate: number,
|
||||||
crossFadeOverlapRate: number,
|
crossFadeOverlapRate: number,
|
||||||
@ -111,6 +114,7 @@ export const ServerSettingKey = {
|
|||||||
"srcId": "srcId",
|
"srcId": "srcId",
|
||||||
"dstId": "dstId",
|
"dstId": "dstId",
|
||||||
"convertChunkNum": "convertChunkNum",
|
"convertChunkNum": "convertChunkNum",
|
||||||
|
"minConvertSize": "minConvertSize",
|
||||||
"gpu": "gpu",
|
"gpu": "gpu",
|
||||||
"crossFadeOffsetRate": "crossFadeOffsetRate",
|
"crossFadeOffsetRate": "crossFadeOffsetRate",
|
||||||
"crossFadeEndRate": "crossFadeEndRate",
|
"crossFadeEndRate": "crossFadeEndRate",
|
||||||
@ -123,6 +127,7 @@ export type ServerSettingKey = typeof ServerSettingKey[keyof typeof ServerSettin
|
|||||||
// Defaults
|
// Defaults
|
||||||
export const DefaultVoiceChangerServerSetting: VoiceChangerServerSetting = {
|
export const DefaultVoiceChangerServerSetting: VoiceChangerServerSetting = {
|
||||||
convertChunkNum: 32, //(★1)
|
convertChunkNum: 32, //(★1)
|
||||||
|
minConvertSize: 0,
|
||||||
srcId: 107,
|
srcId: 107,
|
||||||
dstId: 100,
|
dstId: 100,
|
||||||
gpu: 0,
|
gpu: 0,
|
||||||
|
@ -26,12 +26,13 @@ class VocieChangerSettings():
|
|||||||
crossFadeEndRate:float = 0.9
|
crossFadeEndRate:float = 0.9
|
||||||
crossFadeOverlapRate:float = 0.9
|
crossFadeOverlapRate:float = 0.9
|
||||||
convertChunkNum:int = 32
|
convertChunkNum:int = 32
|
||||||
|
minConvertSize:int = 0
|
||||||
framework:str = "PyTorch" # PyTorch or ONNX
|
framework:str = "PyTorch" # PyTorch or ONNX
|
||||||
pyTorchModelFile:str = ""
|
pyTorchModelFile:str = ""
|
||||||
onnxModelFile:str = ""
|
onnxModelFile:str = ""
|
||||||
configFile:str = ""
|
configFile:str = ""
|
||||||
# ↓mutableな物だけ列挙
|
# ↓mutableな物だけ列挙
|
||||||
intData = ["gpu","srcId", "dstId", "convertChunkNum"]
|
intData = ["gpu","srcId", "dstId", "convertChunkNum", "minConvertSize"]
|
||||||
floatData = [ "crossFadeOffsetRate", "crossFadeEndRate", "crossFadeOverlapRate"]
|
floatData = [ "crossFadeOffsetRate", "crossFadeEndRate", "crossFadeOverlapRate"]
|
||||||
strData = ["framework"]
|
strData = ["framework"]
|
||||||
|
|
||||||
@ -298,8 +299,9 @@ class VoiceChanger():
|
|||||||
|
|
||||||
if unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate) + 1024 > convertSize:
|
if unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate) + 1024 > convertSize:
|
||||||
convertSize = int(unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate)) + 1024
|
convertSize = int(unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate)) + 1024
|
||||||
|
if convertSize < self.settings.minConvertSize:
|
||||||
# print("convert Size", unpackedData.shape[0], unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate), convertSize)
|
convertSize = self.settings.minConvertSize
|
||||||
|
# print("convert Size", unpackedData.shape[0], unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate), convertSize, self.settings.minConvertSize)
|
||||||
|
|
||||||
self._generate_strength(unpackedData)
|
self._generate_strength(unpackedData)
|
||||||
data = self._generate_input(unpackedData, convertSize)
|
data = self._generate_input(unpackedData, convertSize)
|
||||||
|
Loading…
Reference in New Issue
Block a user