-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathconst.ts
More file actions
582 lines (492 loc) · 15.4 KB
/
Copy pathconst.ts
File metadata and controls
582 lines (492 loc) · 15.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
// (★1) chunk sizeは 128サンプル, 256byte(int16)と定義。
// (★2) 256byte(最低バッファサイズ256から間引いた個数x2byte)をchunkとして管理。
// 24000sample -> 1sec, 128sample(1chunk) -> 5.333msec
// 187.5chunk -> 1sec
export const ClientType = {
"MMVCv15": "MMVCv15",
"MMVCv13": "MMVCv13",
"so-vits-svc-40": "so-vits-svc-40",
"so-vits-svc-40_c": "so-vits-svc-40_c",
"so-vits-svc-40v2": "so-vits-svc-40v2",
"DDSP-SVC": "DDSP-SVC",
"RVC": "RVC"
} as const
export type ClientType = typeof ClientType[keyof typeof ClientType]
export const VoiceChangerType = {
"MMVCv15": "MMVCv15",
"MMVCv13": "MMVCv13",
"so-vits-svc-40": "so-vits-svc-40",
"DDSP-SVC": "DDSP-SVC",
"RVC": "RVC"
} as const
export type VoiceChangerType = typeof VoiceChangerType[keyof typeof VoiceChangerType]
///////////////////////
// サーバセッティング
///////////////////////
export const InputSampleRate = {
"48000": 48000,
"44100": 44100,
"24000": 24000
} as const
export type InputSampleRate = typeof InputSampleRate[keyof typeof InputSampleRate]
export const ModelSamplingRate = {
"48000": 48000,
"40000": 40000,
"32000": 32000
} as const
export type ModelSamplingRate = typeof InputSampleRate[keyof typeof InputSampleRate]
export const CrossFadeOverlapSize = {
"1024": 1024,
"2048": 2048,
"4096": 4096,
} as const
export type CrossFadeOverlapSize = typeof CrossFadeOverlapSize[keyof typeof CrossFadeOverlapSize]
export const OnnxExecutionProvider = {
"CPUExecutionProvider": "CPUExecutionProvider",
"CUDAExecutionProvider": "CUDAExecutionProvider",
"DmlExecutionProvider": "DmlExecutionProvider",
"OpenVINOExecutionProvider": "OpenVINOExecutionProvider",
} as const
export type OnnxExecutionProvider = typeof OnnxExecutionProvider[keyof typeof OnnxExecutionProvider]
export const Framework = {
"PyTorch": "PyTorch",
"ONNX": "ONNX",
} as const
export type Framework = typeof Framework[keyof typeof Framework]
export const F0Detector = {
"dio": "dio",
"harvest": "harvest",
// "parselmouth": "parselmouth",
"crepe": "crepe",
} as const
export type F0Detector = typeof F0Detector[keyof typeof F0Detector]
export const DiffMethod = {
"pndm": "pndm",
"dpm-solver": "dpm-solver",
} as const
export type DiffMethod = typeof DiffMethod[keyof typeof DiffMethod]
export const ModelType = {
"pyTorchRVC": "pyTorchRVC",
"pyTorchRVCNono": "pyTorchRVCNono",
"pyTorchRVCv2": "pyTorchRVCv2",
"pyTorchRVCv2Nono": "pyTorchRVCv2Nono",
"pyTorchWebUI": "pyTorchWebUI",
"pyTorchWebUINono": "pyTorchWebUINono",
"onnxRVC": "onnxRVC",
"onnxRVCNono": "onnxRVCNono",
} as const
export type ModelType = typeof ModelType[keyof typeof ModelType]
export const ServerSettingKey = {
"srcId": "srcId",
"dstId": "dstId",
"gpu": "gpu",
"crossFadeOffsetRate": "crossFadeOffsetRate",
"crossFadeEndRate": "crossFadeEndRate",
"crossFadeOverlapSize": "crossFadeOverlapSize",
"framework": "framework",
"onnxExecutionProvider": "onnxExecutionProvider",
"f0Factor": "f0Factor",
"f0Detector": "f0Detector",
"recordIO": "recordIO",
"enableServerAudio": "enableServerAudio",
"serverAudioStated": "serverAudioStated",
"serverInputAudioSampleRate": "serverInputAudioSampleRate",
"serverOutputAudioSampleRate": "serverOutputAudioSampleRate",
"serverInputAudioBufferSize": "serverInputAudioBufferSize",
"serverOutputAudioBufferSize": "serverOutputAudioBufferSize",
"serverInputDeviceId": "serverInputDeviceId",
"serverOutputDeviceId": "serverOutputDeviceId",
"serverReadChunkSize": "serverReadChunkSize",
"serverInputAudioGain": "serverInputAudioGain",
"serverOutputAudioGain": "serverOutputAudioGain",
"tran": "tran",
"noiseScale": "noiseScale",
"predictF0": "predictF0",
"silentThreshold": "silentThreshold",
"extraConvertSize": "extraConvertSize",
"clusterInferRatio": "clusterInferRatio",
"indexRatio": "indexRatio",
"protect": "protect",
"rvcQuality": "rvcQuality",
"modelSamplingRate": "modelSamplingRate",
"silenceFront": "silenceFront",
// "modelSlotIndex": "modelSlotIndex",
"slotIndex": "slotIndex",
"useEnhancer": "useEnhancer",
"useDiff": "useDiff",
// "useDiffDpm": "useDiffDpm",
"diffMethod": "diffMethod",
"useDiffSilence": "useDiffSilence",
"diffAcc": "diffAcc",
"diffSpkId": "diffSpkId",
"kStep": "kStep",
"threshold": "threshold",
"inputSampleRate": "inputSampleRate",
"enableDirectML": "enableDirectML",
} as const
export type ServerSettingKey = typeof ServerSettingKey[keyof typeof ServerSettingKey]
export type VoiceChangerServerSetting = {
srcId: number,
dstId: number,
gpu: number,
crossFadeOffsetRate: number,
crossFadeEndRate: number,
crossFadeOverlapSize: CrossFadeOverlapSize,
framework: Framework
onnxExecutionProvider: OnnxExecutionProvider,
f0Factor: number
f0Detector: F0Detector // dio or harvest
recordIO: number // 0:off, 1:on
enableServerAudio: number // 0:off, 1:on
serverAudioStated: number // 0:off, 1:on
serverInputAudioSampleRate: number
serverOutputAudioSampleRate: number
serverInputAudioBufferSize: number
serverOutputAudioBufferSize: number
serverInputDeviceId: number
serverOutputDeviceId: number
serverReadChunkSize: number
serverInputAudioGain: number
serverOutputAudioGain: number
tran: number // so-vits-svc
noiseScale: number // so-vits-svc
predictF0: number // so-vits-svc
silentThreshold: number // so-vits-svc
extraConvertSize: number// so-vits-svc
clusterInferRatio: number // so-vits-svc
indexRatio: number // RVC
protect: number // RVC
rvcQuality: number // 0:low, 1:high
silenceFront: number // 0:off, 1:on
modelSamplingRate: ModelSamplingRate // 32000,40000,48000
// modelSlotIndex: number,
slotIndex: number,
useEnhancer: number// DDSP-SVC
useDiff: number// DDSP-SVC
// useDiffDpm: number// DDSP-SVC
diffMethod: DiffMethod, // DDSP-SVC
useDiffSilence: number// DDSP-SVC
diffAcc: number// DDSP-SVC
diffSpkId: number// DDSP-SVC
kStep: number// DDSP-SVC
threshold: number// DDSP-SVC
inputSampleRate: InputSampleRate
enableDirectML: number
}
// type ModelSlot = {
// modelFile: string
// featureFile: string,
// indexFile: string,
// defaultTune: number,
// defaultIndexRatio: number,
// defaultProtect: number,
// modelType: ModelType,
// embChannels: number,
// f0: boolean,
// samplingRate: number
// deprecated: boolean
// name: string,
// description: string,
// credit: string,
// termsOfUseUrl: string,
// iconFile: string
// }
type SlotInfo = {
voiceChangerType: VoiceChangerType | null
modelFile: string
featureFile: string,
indexFile: string,
defaultTune: number,
defaultIndexRatio: number,
defaultProtect: number,
modelType: ModelType,
embChannels: number,
f0: boolean,
samplingRate: number
deprecated: boolean
name: string,
description: string,
credit: string,
termsOfUseUrl: string,
iconFile: string
}
type ServerAudioDevice = {
kind: "audioinput" | "audiooutput",
index: number,
name: string
hostAPI: string
}
export type ServerInfo = VoiceChangerServerSetting & {
status: string
configFile: string,
pyTorchModelFile: string,
onnxModelFile: string,
onnxExecutionProviders: OnnxExecutionProvider[]
// modelSlots: ModelSlot[]
slotInfos: SlotInfo[]
serverAudioInputDevices: ServerAudioDevice[]
serverAudioOutputDevices: ServerAudioDevice[]
sampleModels: RVCSampleModel[]
gpus: {
id: number,
name: string,
memory: number,
}[]
}
export type ServerInfoSoVitsSVC = ServerInfo & {
speakers: { [key: string]: number }
}
export type RVCSampleModel = {
id: string
name: string
modelUrl: string
indexUrl: string
featureUrl: string
termsOfUseUrl: string
credit: string
description: string
lang: string
tag: string[]
icon: string
f0: boolean
sampleRate: number
modelType: string
}
export const DefaultServerSetting: ServerInfo = {
// VC Common
inputSampleRate: 48000,
crossFadeOffsetRate: 0.0,
crossFadeEndRate: 1.0,
crossFadeOverlapSize: CrossFadeOverlapSize[1024],
recordIO: 0,
enableServerAudio: 0,
serverAudioStated: 0,
serverInputAudioSampleRate: 48000,
serverOutputAudioSampleRate: 48000,
serverInputAudioBufferSize: 1024 * 24,
serverOutputAudioBufferSize: 1024 * 24,
serverInputDeviceId: -1,
serverOutputDeviceId: -1,
serverReadChunkSize: 256,
serverInputAudioGain: 1.0,
serverOutputAudioGain: 1.0,
// VC Specific
srcId: 0,
dstId: 1,
gpu: 0,
framework: Framework.PyTorch,
f0Factor: 1.0,
onnxExecutionProvider: OnnxExecutionProvider.CPUExecutionProvider,
f0Detector: F0Detector.dio,
tran: 0,
noiseScale: 0,
predictF0: 0,
silentThreshold: 0,
extraConvertSize: 0,
clusterInferRatio: 0,
indexRatio: 0,
protect: 0.5,
rvcQuality: 0,
modelSamplingRate: 48000,
silenceFront: 1,
// modelSlotIndex: 0,
slotIndex: 0,
sampleModels: [],
gpus: [],
useEnhancer: 0,
useDiff: 1,
diffMethod: "dpm-solver",
useDiffSilence: 0,
diffAcc: 20,
diffSpkId: 1,
kStep: 120,
threshold: -45,
enableDirectML: 0,
//
status: "ok",
configFile: "",
pyTorchModelFile: "",
onnxModelFile: "",
onnxExecutionProviders: [],
// modelSlots: [],
slotInfos: [],
serverAudioInputDevices: [],
serverAudioOutputDevices: []
}
export const DefaultServerSetting_MMVCv15: ServerInfo = {
...DefaultServerSetting, dstId: 101,
}
export const DefaultServerSetting_MMVCv13: ServerInfo = {
...DefaultServerSetting, srcId: 107, dstId: 100,
}
export const DefaultServerSetting_so_vits_svc_40: ServerInfo = {
...DefaultServerSetting, tran: 10, noiseScale: 0.3, extraConvertSize: 1024 * 8, clusterInferRatio: 0.1,
}
export const DefaultServerSetting_so_vits_svc_40_c: ServerInfo = {
...DefaultServerSetting, tran: 10, noiseScale: 0.3, extraConvertSize: 1024 * 8, clusterInferRatio: 0.1,
}
export const DefaultServerSetting_so_vits_svc_40v2: ServerInfo = {
...DefaultServerSetting, tran: 10, noiseScale: 0.3, extraConvertSize: 1024 * 8, clusterInferRatio: 0.1,
}
export const DefaultServerSetting_DDSP_SVC: ServerInfo = {
...DefaultServerSetting, dstId: 1, tran: 10, extraConvertSize: 1024 * 8
}
export const DefaultServerSetting_RVC: ServerInfo = {
...DefaultServerSetting, tran: 10, extraConvertSize: 1024 * 4, f0Detector: F0Detector.harvest
}
///////////////////////
// Workletセッティング
///////////////////////
export type WorkletSetting = {
numTrancateTreshold: number,
volTrancateThreshold: number,
volTrancateLength: number
}
export const DefaultWorkletSetting: WorkletSetting = {
numTrancateTreshold: 100,
volTrancateThreshold: 0.0005,
volTrancateLength: 32
}
///////////////////////
// Worklet Nodeセッティング
///////////////////////
export const Protocol = {
"sio": "sio",
"rest": "rest",
} as const
export type Protocol = typeof Protocol[keyof typeof Protocol]
export const SendingSampleRate = {
"48000": 48000,
"44100": 44100,
"24000": 24000
} as const
export type SendingSampleRate = typeof SendingSampleRate[keyof typeof SendingSampleRate]
export const DownSamplingMode = {
"decimate": "decimate",
"average": "average"
} as const
export type DownSamplingMode = typeof DownSamplingMode[keyof typeof DownSamplingMode]
export type WorkletNodeSetting = {
serverUrl: string,
protocol: Protocol,
sendingSampleRate: SendingSampleRate,
inputChunkNum: number,
downSamplingMode: DownSamplingMode,
}
export const DefaultWorkletNodeSetting: WorkletNodeSetting = {
serverUrl: "",
protocol: "sio",
sendingSampleRate: 48000,
inputChunkNum: 48,
downSamplingMode: "average"
}
export const DefaultWorkletNodeSetting_so_vits_svc_40: WorkletNodeSetting = {
...DefaultWorkletNodeSetting, inputChunkNum: 128,
}
export const DefaultWorkletNodeSetting_so_vits_svc_40v2: WorkletNodeSetting = {
...DefaultWorkletNodeSetting, inputChunkNum: 128,
}
export const DefaultWorkletNodeSetting_DDSP_SVC: WorkletNodeSetting = {
...DefaultWorkletNodeSetting, inputChunkNum: 256,
}
export const DefaultWorkletNodeSetting_RVC: WorkletNodeSetting = {
...DefaultWorkletNodeSetting, inputChunkNum: 256,
}
///////////////////////
// クライアントセッティング
///////////////////////
export const SampleRate = {
"48000": 48000,
} as const
export type SampleRate = typeof SampleRate[keyof typeof SampleRate]
export type Speaker = {
"id": number,
"name": string,
}
export type Correspondence = {
"sid": number,
"correspondence": number,
"dirname": string
}
export type VoiceChangerClientSetting = {
audioInput: string | MediaStream | null,
sampleRate: SampleRate, // 48000Hz
echoCancel: boolean,
noiseSuppression: boolean,
noiseSuppression2: boolean
speakers: Speaker[],
correspondences: Correspondence[],
inputGain: number
outputGain: number
}
export const DefaultVoiceChangerClientSetting: VoiceChangerClientSetting = {
audioInput: null,
sampleRate: 48000,
speakers: [
{
"id": 0,
"name": "user"
},
{
"id": 101,
"name": "ずんだもん"
},
{
"id": 102,
"name": "そら"
},
{
"id": 103,
"name": "めたん"
},
{
"id": 104,
"name": "つむぎ"
}
],
correspondences: [],
echoCancel: false,
noiseSuppression: false,
noiseSuppression2: false,
inputGain: 1.0,
outputGain: 1.0
}
////////////////////////////////////
// Exceptions
////////////////////////////////////
export const VOICE_CHANGER_CLIENT_EXCEPTION = {
ERR_SIO_CONNECT_FAILED: "ERR_SIO_CONNECT_FAILED",
ERR_SIO_INVALID_RESPONSE: "ERR_SIO_INVALID_RESPONSE",
ERR_REST_INVALID_RESPONSE: "ERR_REST_INVALID_RESPONSE",
ERR_MIC_STREAM_NOT_INITIALIZED: "ERR_MIC_STREAM_NOT_INITIALIZED"
} as const
export type VOICE_CHANGER_CLIENT_EXCEPTION = typeof VOICE_CHANGER_CLIENT_EXCEPTION[keyof typeof VOICE_CHANGER_CLIENT_EXCEPTION]
////////////////////////////////////
// indexedDB
////////////////////////////////////
export const INDEXEDDB_DB_APP_NAME = "INDEXEDDB_KEY_VOICE_CHANGER"
export const INDEXEDDB_DB_NAME = "INDEXEDDB_KEY_VOICE_CHANGER_DB"
export const INDEXEDDB_KEY_CLIENT = "INDEXEDDB_KEY_VOICE_CHANGER_LIB_CLIENT"
export const INDEXEDDB_KEY_SERVER = "INDEXEDDB_KEY_VOICE_CHANGER_LIB_SERVER"
export const INDEXEDDB_KEY_WORKLETNODE = "INDEXEDDB_KEY_VOICE_CHANGER_LIB_WORKLETNODE"
export const INDEXEDDB_KEY_MODEL_DATA = "INDEXEDDB_KEY_VOICE_CHANGER_LIB_MODEL_DATA"
export const INDEXEDDB_KEY_WORKLET = "INDEXEDDB_KEY_VOICE_CHANGER_LIB_WORKLET"
// ONNX
export type OnnxExporterInfo = {
"status": string
"path": string
"filename": string
}
export const MAX_MODEL_SLOT_NUM = 4
// Merge
export type MergeElement = {
filename: string
strength: number
}
export type MergeModelRequest = {
command: "mix",
defaultTune: number,
defaultIndexRatio: number,
defaultProtect: number,
files: MergeElement[]
}