add lang filter

This commit is contained in:
wataru 2023-05-18 04:08:13 +09:00
parent e9c844b882
commit 3bf1aacd05
7 changed files with 35 additions and 15 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@dannadori/voice-changer-client-js": "^1.0.128",
"@dannadori/voice-changer-client-js": "^1.0.129",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
@ -3170,9 +3170,9 @@
}
},
"node_modules/@dannadori/voice-changer-client-js": {
"version": "1.0.128",
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.128.tgz",
"integrity": "sha512-UTzJla1uIyARbfFSMXxr0nAQx8KDDakSx1VlZ3wZQTeo150hT3Fi/pZEoYtzIPe2zLu+R7EWVl9B0ZIjgjlQgA==",
"version": "1.0.129",
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.129.tgz",
"integrity": "sha512-paWIzC/mepe3wC162U45ReIEl5rWmMu/+TtNVrabeAhkRWrZJfLsD6v95E+A5whalKA0YYk6m0B6YahtVAw6Aw==",
"dependencies": {
"@types/readable-stream": "^2.3.15",
"amazon-chime-sdk-js": "^3.14.0",
@ -13995,9 +13995,9 @@
}
},
"@dannadori/voice-changer-client-js": {
"version": "1.0.128",
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.128.tgz",
"integrity": "sha512-UTzJla1uIyARbfFSMXxr0nAQx8KDDakSx1VlZ3wZQTeo150hT3Fi/pZEoYtzIPe2zLu+R7EWVl9B0ZIjgjlQgA==",
"version": "1.0.129",
"resolved": "https://registry.npmjs.org/@dannadori/voice-changer-client-js/-/voice-changer-client-js-1.0.129.tgz",
"integrity": "sha512-paWIzC/mepe3wC162U45ReIEl5rWmMu/+TtNVrabeAhkRWrZJfLsD6v95E+A5whalKA0YYk6m0B6YahtVAw6Aw==",
"requires": {
"@types/readable-stream": "^2.3.15",
"amazon-chime-sdk-js": "^3.14.0",

View File

@ -52,7 +52,7 @@
"webpack-dev-server": "^4.15.0"
},
"dependencies": {
"@dannadori/voice-changer-client-js": "^1.0.128",
"@dannadori/voice-changer-client-js": "^1.0.129",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-brands-svg-icons": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",

View File

@ -1,4 +1,4 @@
import React, { useMemo } from "react"
import React, { useMemo, useState } from "react"
import { useAppState } from "../../../001_provider/001_AppStateProvider"
import { useGuiState } from "../001_GuiStateProvider"
@ -6,6 +6,7 @@ export type SampleModelSelectRowProps = {}
export const SampleModelSelectRow = (_props: SampleModelSelectRowProps) => {
const appState = useAppState()
const guiState = useGuiState()
const [lang, setLang] = useState<string>("All")
const sampleModelSelectRow = useMemo(() => {
const slot = guiState.modelSlotNum
const fileUploadSetting = appState.serverSetting.fileUploadSettings[slot]
@ -16,12 +17,26 @@ export const SampleModelSelectRow = (_props: SampleModelSelectRowProps) => {
return <></>
}
const langs = appState.serverSetting.serverSetting.sampleModels.reduce((prev, cur) => {
if (prev.includes(cur.lang) == false) {
prev.push(cur.lang)
}
return prev
}, ["All"] as string[])
const langOptions = (
langs.map(x => {
return <option key={x} value={x}>{x}</option>
})
)
const options = (
appState.serverSetting.serverSetting.sampleModels.map(x => {
appState.serverSetting.serverSetting.sampleModels.filter(x => { return lang == "All" ? true : x.lang == lang }).map(x => {
return <option key={x.id} value={x.id}>{x.name}</option>
})
)
const selectedSample = appState.serverSetting.serverSetting.sampleModels.find(x => { return x.id == fileUploadSetting.sampleId })
const creditText = selectedSample ? `credit:${selectedSample.credit}` : ""
const termOfUseLink = selectedSample ? <a href={selectedSample.termsOfUseUrl} target="_blank" rel="noopener noreferrer" className="body-item-text-small">[terms of use]</a> : <></>
@ -36,6 +51,9 @@ export const SampleModelSelectRow = (_props: SampleModelSelectRowProps) => {
<div className="body-row split-3-3-4 left-padding-1 guided">
<div className="body-item-title left-padding-2 ">Select Model</div>
<div>
<select value={lang} onChange={(e) => { setLang(e.target.value) }}>
{langOptions}
</select>
<select value={fileUploadSetting.sampleId || ""} onChange={(e) => { onModelSelected(e.target.value) }}>
<option disabled value={""}> -- select model -- </option>
{options}
@ -47,7 +65,7 @@ export const SampleModelSelectRow = (_props: SampleModelSelectRowProps) => {
</div>
)
}, [appState.serverSetting.fileUploadSettings, guiState.modelSlotNum])
}, [appState.serverSetting.fileUploadSettings, guiState.modelSlotNum, lang])
return sampleModelSelectRow
}

View File

@ -1,12 +1,12 @@
{
"name": "@dannadori/voice-changer-client-js",
"version": "1.0.128",
"version": "1.0.129",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@dannadori/voice-changer-client-js",
"version": "1.0.128",
"version": "1.0.129",
"license": "ISC",
"dependencies": {
"@types/readable-stream": "^2.3.15",

View File

@ -1,6 +1,6 @@
{
"name": "@dannadori/voice-changer-client-js",
"version": "1.0.128",
"version": "1.0.129",
"description": "",
"main": "dist/index.js",
"directories": {

View File

@ -234,6 +234,8 @@ export type RVCSampleModel = {
termsOfUseUrl: string
credit: string
description: string
lang: string
tag: string
}
export const DefaultServerSetting: ServerInfo = {