improve library exception

This commit is contained in:
wataru 2023-06-11 10:55:26 +09:00
parent 74d277714b
commit e6b58a8613
11 changed files with 1969 additions and 71 deletions

View File

@ -1 +1,10 @@
<!doctype html><html style="width:100%;height:100%;overflow:hidden"><head><meta charset="utf-8"/><title>Voice Changer Client Demo</title><script defer="defer" src="index.js"></script></head><body style="width:100%;height:100%;margin:0"><div id="app" style="width:100%;height:100%"></div></body></html>
<!DOCTYPE html>
<html style="width: 100%; height: 100%; overflow: hidden">
<head>
<meta charset="utf-8" />
<title>Voice Changer Client Demo</title>
<script defer src="index.js"></script></head>
<body style="width: 100%; height: 100%; margin: 0px">
<div id="app" style="width: 100%; height: 100%"></div>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@ -1,31 +0,0 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
/**
* @license React
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* @license React
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

View File

@ -10,7 +10,6 @@ export type TitleProps = {
export const Title = (props: TitleProps) => {
const githubLink = useMemo(() => {
return isDesktopApp() ?
(

View File

@ -58,6 +58,13 @@ export const AppStateProvider = ({ children }: Props) => {
}
}, [clientState.clientState.initialized])
useEffect(() => {
if (clientState.clientState.ioErrorCount > 100) {
alert("エラーが頻発しています。対象としているフレームワークのモデルがロードされているか確認してください。")
clientState.clientState.resetIoErrorCount()
}
}, [clientState.clientState.ioErrorCount])
const providerValue: AppStateValue = {

View File

@ -258,7 +258,11 @@ export const ModelSlotManagerDialog = () => {
sampleId: id,
isSampleMode: true
}
try {
await serverSetting.loadModel(fromNetTargetIndex)
} catch (e) {
alert(e)
}
setMode("localFile")
}
const options = (

View File

@ -15,7 +15,12 @@ export const ModelUploadButtonRow2 = (_props: ModelUploadButtonRow2Props) => {
return <></>
}
const onModelUploadClicked = async () => {
appState.serverSetting.loadModel(slot)
try {
await appState.serverSetting.loadModel(slot)
} catch (e) {
console.log(e)
alert(e)
}
}
const buttonText = appState.serverSetting.fileUploadSettings[slot].isSampleMode ? "select" : "upload"

View File

@ -0,0 +1,9 @@
export class ModelLoadException extends Error {
public causeFileType: string = ""
constructor(causeFileType: string) {
super(`Model Load Exception:${causeFileType}`);
this.causeFileType = causeFileType;
this.name = this.constructor.name;
Error.captureStackTrace(this);
}
}

View File

@ -34,6 +34,9 @@ export type ClientState = {
clearSetting: () => Promise<void>
// AudioOutputElement 設定
setAudioOutputElementId: (elemId: string) => void
ioErrorCount: number
resetIoErrorCount: () => void
}
export type PerformanceData = {
@ -77,6 +80,7 @@ export const useClient = (props: UseClientProps): ClientState => {
const [bufferingTime, setBufferingTime] = useState<number>(0)
const [performance, setPerformance] = useState<PerformanceData>(InitialPerformanceData)
const [volume, setVolume] = useState<number>(0)
const [ioErrorCount, setIoErrorCount] = useState<number>(0)
//// Server Audio Deviceを使うとき、モニタリングデータはpolling
const updatePerformance = useMemo(() => {
@ -105,7 +109,11 @@ export const useClient = (props: UseClientProps): ClientState => {
// (1-4) エラーステータス
const errorCountRef = useRef<number>(0)
const ioErrorCountRef = useRef<number>(0)
const resetIoErrorCount = () => {
ioErrorCountRef.current = 0
setIoErrorCount(ioErrorCountRef.current)
}
// (2-1) 初期化処理
useEffect(() => {
@ -127,11 +135,8 @@ export const useClient = (props: UseClientProps): ClientState => {
notifyException: (mes: string) => {
if (mes.length > 0) {
console.log(`error:${mes}`)
errorCountRef.current += 1
if (errorCountRef.current > 100) {
alert("エラーが頻発しています。対象としているフレームワークのモデルがロードされているか確認してください。")
errorCountRef.current = 0
}
ioErrorCountRef.current += 1
setIoErrorCount(ioErrorCountRef.current)
}
},
notifyVolume: (vol: number) => {
@ -207,5 +212,8 @@ export const useClient = (props: UseClientProps): ClientState => {
// AudioOutputElement 設定
setAudioOutputElementId,
ioErrorCount,
resetIoErrorCount
}
}

View File

@ -2,6 +2,7 @@ import { useState, useMemo, useEffect } from "react"
import { VoiceChangerServerSetting, ServerInfo, ServerSettingKey, INDEXEDDB_KEY_SERVER, INDEXEDDB_KEY_MODEL_DATA, ClientType, DefaultServerSetting_MMVCv13, DefaultServerSetting_MMVCv15, DefaultServerSetting_so_vits_svc_40v2, DefaultServerSetting_so_vits_svc_40, DefaultServerSetting_so_vits_svc_40_c, DefaultServerSetting_RVC, OnnxExporterInfo, DefaultServerSetting_DDSP_SVC, MAX_MODEL_SLOT_NUM, Framework, MergeModelRequest } from "../const"
import { VoiceChangerClient } from "../VoiceChangerClient"
import { useIndexedDB } from "./useIndexedDB"
import { ModelLoadException } from "../exceptions"
type ModelData = {
@ -265,68 +266,54 @@ export const useServerSetting = (props: UseServerSettingProps): ServerSettingSta
if (fileUploadSetting.isSampleMode == false) {
if (props.clientType == "MMVCv13") {
if (!fileUploadSetting.mmvcv13Config) {
alert("Configファイルを指定する必要があります。")
return
throw new ModelLoadException("Config")
}
if (!fileUploadSetting.mmvcv13Model) {
alert("モデルファイルを指定する必要があります。")
return
throw new ModelLoadException("Model")
}
} else if (props.clientType == "MMVCv15") {
if (!fileUploadSetting.mmvcv15Config) {
alert("Configファイルを指定する必要があります。")
return
throw new ModelLoadException("Config")
}
if (!fileUploadSetting.mmvcv15Model) {
alert("モデルファイルを指定する必要があります。")
return
throw new ModelLoadException("Model")
}
} else if (props.clientType == "so-vits-svc-40") {
if (!fileUploadSetting.soVitsSvc40Config) {
alert("Configファイルを指定する必要があります。")
return
throw new ModelLoadException("Config")
}
if (!fileUploadSetting.soVitsSvc40Model) {
alert("モデルファイルを指定する必要があります。")
return
throw new ModelLoadException("Model")
}
} else if (props.clientType == "so-vits-svc-40v2") {
if (!fileUploadSetting.soVitsSvc40v2Config) {
alert("Configファイルを指定する必要があります。")
return
throw new ModelLoadException("Config")
}
if (!fileUploadSetting.soVitsSvc40v2Model) {
alert("モデルファイルを指定する必要があります。")
return
throw new ModelLoadException("Model")
}
} else if (props.clientType == "RVC") {
if (!fileUploadSetting.rvcModel) {
alert("モデルファイルを指定する必要があります。")
return
throw new ModelLoadException("Model")
}
} else if (props.clientType == "DDSP-SVC") {
if (!fileUploadSetting.ddspSvcModel) {
alert("DDSPモデルを指定する必要があります。")
return
throw new ModelLoadException("DDSP-Model")
}
if (!fileUploadSetting.ddspSvcModelConfig) {
alert("DDSP Configファイルを指定する必要があります。")
return
throw new ModelLoadException("DDSP-Config")
}
if (!fileUploadSetting.ddspSvcDiffusion) {
alert("Diffusionモデルを指定する必要があります。")
return
throw new ModelLoadException("Diff-Model")
}
if (!fileUploadSetting.ddspSvcDiffusionConfig) {
alert("Diffusion Configファイルを指定する必要があります。")
return
throw new ModelLoadException("Diff-Config")
}
} else {
}
} else {//Sampleモード
if (!fileUploadSetting.sampleId) {
alert("Sample IDを指定する必要があります。")
return
throw new ModelLoadException("SampleId")
}
}

View File

@ -1,4 +1,5 @@
export * from "./const"
export * from "./exceptions"
export * from "./VoiceChangerClient"
export * from "./util"
export * from "./hooks/useClient"