mirror of
https://github.com/w-okada/voice-changer.git
synced 2025-01-23 13:35:12 +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 { useMemo } from "react"
|
||||
import { ClientState } from "./hooks/useClient"
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { BufferSize } from "@dannadori/voice-changer-client-js"
|
||||
import React, { useMemo, useState } from "react"
|
||||
import React, { useMemo } from "react"
|
||||
import { ClientState } from "./hooks/useClient"
|
||||
|
||||
export type UseConvertSettingProps = {
|
||||
|
@ -108,6 +108,20 @@ export const useAdvancedSetting = (props: UseAdvancedSettingProps): AdvancedSett
|
||||
)
|
||||
}, [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(() => {
|
||||
return (
|
||||
<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>
|
||||
|
||||
{convertChunkNumRow}
|
||||
{minConvertSizeRow}
|
||||
{crossFadeOverlapRateRow}
|
||||
{crossFadeOffsetRateRow}
|
||||
{crossFadeEndRateRow}
|
||||
@ -251,7 +266,7 @@ export const useAdvancedSetting = (props: UseAdvancedSettingProps): AdvancedSett
|
||||
<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(() => {
|
||||
|
@ -25,6 +25,7 @@ export type ServerSettingState = {
|
||||
setSrcId: (num: number) => Promise<boolean>;
|
||||
setDstId: (num: number) => Promise<boolean>;
|
||||
setConvertChunkNum: (num: number) => Promise<boolean>;
|
||||
setMinConvertSize: (num: number) => Promise<boolean>
|
||||
setGpu: (num: number) => Promise<boolean>;
|
||||
setCrossFadeOffsetRate: (num: number) => Promise<boolean>;
|
||||
setCrossFadeEndRate: (num: number) => Promise<boolean>;
|
||||
@ -56,6 +57,7 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
||||
_setSetting({
|
||||
...settingRef.current,
|
||||
convertChunkNum: res.convertChunkNum,
|
||||
minConvertSize: res.minConvertSize,
|
||||
srcId: res.srcId,
|
||||
dstId: res.dstId,
|
||||
gpu: res.gpu,
|
||||
@ -103,6 +105,13 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
||||
}
|
||||
}, [props.voiceChangerClient])
|
||||
|
||||
const setMinConvertSize = useMemo(() => {
|
||||
return async (num: number) => {
|
||||
return await _set_and_store(ServerSettingKey.minConvertSize, "" + num)
|
||||
}
|
||||
}, [props.voiceChangerClient])
|
||||
|
||||
|
||||
const setGpu = useMemo(() => {
|
||||
return async (num: number) => {
|
||||
return await _set_and_store(ServerSettingKey.gpu, "" + num)
|
||||
@ -125,6 +134,8 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
||||
}
|
||||
}, [props.voiceChangerClient])
|
||||
|
||||
|
||||
|
||||
//////////////
|
||||
// 操作
|
||||
/////////////
|
||||
@ -218,6 +229,7 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
|
||||
setSrcId,
|
||||
setDstId,
|
||||
setConvertChunkNum,
|
||||
setMinConvertSize,
|
||||
setGpu,
|
||||
setCrossFadeOffsetRate,
|
||||
setCrossFadeEndRate,
|
||||
|
@ -7,6 +7,8 @@
|
||||
// types
|
||||
export type VoiceChangerServerSetting = {
|
||||
convertChunkNum: number, // VITSに入力する変換サイズ。(入力データの2倍以上の大きさで指定。それより小さいものが指定された場合は、サーバ側で自動的に入力の2倍のサイズが設定される。)
|
||||
minConvertSize: number, // この値より小さい場合にこの値に揃える。
|
||||
|
||||
srcId: number,
|
||||
dstId: number,
|
||||
gpu: number,
|
||||
@ -50,6 +52,7 @@ export type ServerInfo = {
|
||||
pyTorchModelFile: string,
|
||||
onnxModelFile: string,
|
||||
convertChunkNum: number,
|
||||
minConvertSize: number,
|
||||
crossFadeOffsetRate: number,
|
||||
crossFadeEndRate: number,
|
||||
crossFadeOverlapRate: number,
|
||||
@ -111,6 +114,7 @@ export const ServerSettingKey = {
|
||||
"srcId": "srcId",
|
||||
"dstId": "dstId",
|
||||
"convertChunkNum": "convertChunkNum",
|
||||
"minConvertSize": "minConvertSize",
|
||||
"gpu": "gpu",
|
||||
"crossFadeOffsetRate": "crossFadeOffsetRate",
|
||||
"crossFadeEndRate": "crossFadeEndRate",
|
||||
@ -123,6 +127,7 @@ export type ServerSettingKey = typeof ServerSettingKey[keyof typeof ServerSettin
|
||||
// Defaults
|
||||
export const DefaultVoiceChangerServerSetting: VoiceChangerServerSetting = {
|
||||
convertChunkNum: 32, //(★1)
|
||||
minConvertSize: 0,
|
||||
srcId: 107,
|
||||
dstId: 100,
|
||||
gpu: 0,
|
||||
|
@ -26,12 +26,13 @@ class VocieChangerSettings():
|
||||
crossFadeEndRate:float = 0.9
|
||||
crossFadeOverlapRate:float = 0.9
|
||||
convertChunkNum:int = 32
|
||||
minConvertSize:int = 0
|
||||
framework:str = "PyTorch" # PyTorch or ONNX
|
||||
pyTorchModelFile:str = ""
|
||||
onnxModelFile:str = ""
|
||||
configFile:str = ""
|
||||
# ↓mutableな物だけ列挙
|
||||
intData = ["gpu","srcId", "dstId", "convertChunkNum"]
|
||||
intData = ["gpu","srcId", "dstId", "convertChunkNum", "minConvertSize"]
|
||||
floatData = [ "crossFadeOffsetRate", "crossFadeEndRate", "crossFadeOverlapRate"]
|
||||
strData = ["framework"]
|
||||
|
||||
@ -298,8 +299,9 @@ class VoiceChanger():
|
||||
|
||||
if unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate) + 1024 > convertSize:
|
||||
convertSize = int(unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate)) + 1024
|
||||
|
||||
# print("convert Size", unpackedData.shape[0], unpackedData.shape[0]*(1 + self.settings.crossFadeOverlapRate), convertSize)
|
||||
if convertSize < self.settings.minConvertSize:
|
||||
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)
|
||||
data = self._generate_input(unpackedData, convertSize)
|
||||
|
Loading…
Reference in New Issue
Block a user