mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-03 00:47:53 +00:00
Add "text_pipeline_type" to model view and edit pages
This commit is contained in:
1 parent
9e1fb8ea28
commit
a82db9978c
4 files changed
+50
-2
No files matched your search
@@ -4,6 +4,8 @@ export interface TtsModel {
|
||||
model_token: string,
|
||||
title: string,
|
||||
tts_model_type: string,
|
||||
text_pipeline_type: string | null,
|
||||
text_pipeline_type_guess: string,
|
||||
maybe_default_pretrained_vocoder: string | null,
|
||||
text_preprocessing_algorithm: string,
|
||||
creator_user_token: string,
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
// Friendly names for each of the text pipeline identifiers.
|
||||
const TEXT_PIPELINE_NAMES : Map<string, string> = new Map([
|
||||
//["legacy_vocodes", "Legacy Vocodes"],
|
||||
["legacy_fakeyou", "Legacy FakeYou (grapheme-focused)"],
|
||||
["english_v1", "English v1 (Arpabet)"],
|
||||
//["spanish_v1", "Spanish v1"],
|
||||
//["spanish_v2", "Spanish v2"],
|
||||
]);
|
||||
|
||||
export { TEXT_PIPELINE_NAMES }
|
||||
@@ -12,6 +12,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faHeadphones, faHome, faRobot } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faTwitch } from '@fortawesome/free-brands-svg-icons';
|
||||
import { DEFAULT_MODEL_LANGUAGE, SUPPORTED_MODEL_LANGUAGE_TAG_TO_FULL } from '@storyteller/components/src/i18n/SupportedModelLanguages';
|
||||
import { TEXT_PIPELINE_NAMES } from '@storyteller/components/src/constants/TextPipeline';
|
||||
|
||||
const DEFAULT_VISIBILITY = 'public';
|
||||
|
||||
@@ -34,6 +35,7 @@ function TtsModelEditFc(props: Props) {
|
||||
|
||||
// Fields
|
||||
const [title, setTitle] = useState("");
|
||||
const [textPipelineType, setTextPipelineType] = useState<string|null>(null);
|
||||
const [descriptionMarkdown, setDescriptionMarkdown] = useState("");
|
||||
const [fullLanguageTag, setFullLanguageTag] = useState(""); // NB: Should be full IETF, eg. ["en", "en-US", "es-419", etc.]
|
||||
const [visibility, setVisibility] = useState(DEFAULT_VISIBILITY);
|
||||
@@ -48,6 +50,10 @@ function TtsModelEditFc(props: Props) {
|
||||
if (GetTtsModelIsOk(model)) {
|
||||
setTtsModel(model);
|
||||
|
||||
// NB: empty string isn't a correct value for Rust to parse as an enum
|
||||
// Server will also try to send us a guess if we don't have a value set in the DB.
|
||||
setTextPipelineType(model.text_pipeline_type || model.text_pipeline_type_guess || null)
|
||||
|
||||
setTitle(model.title || "")
|
||||
setDescriptionMarkdown(model.description_markdown || "")
|
||||
setFullLanguageTag(model.ietf_language_tag || DEFAULT_MODEL_LANGUAGE)
|
||||
@@ -78,6 +84,10 @@ function TtsModelEditFc(props: Props) {
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleTextPipelineChange = (ev: React.FormEvent<HTMLSelectElement>) => {
|
||||
setTextPipelineType((ev.target as HTMLSelectElement).value)
|
||||
};
|
||||
|
||||
const handleDescriptionMarkdownChange = (ev: React.FormEvent<HTMLTextAreaElement>) => {
|
||||
ev.preventDefault();
|
||||
const textValue = (ev.target as HTMLTextAreaElement).value;
|
||||
@@ -139,6 +149,7 @@ function TtsModelEditFc(props: Props) {
|
||||
creator_set_visibility: visibility || DEFAULT_VISIBILITY,
|
||||
maybe_default_pretrained_vocoder: defaultPretrainedVocoder || DEFAULT_PRETRAINED_VOCODER,
|
||||
ietf_language_tag: fullLanguageTag || DEFAULT_MODEL_LANGUAGE,
|
||||
text_pipeline_type: textPipelineType,
|
||||
}
|
||||
|
||||
if (isModerator) {
|
||||
@@ -311,6 +322,23 @@ function TtsModelEditFc(props: Props) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="field">
|
||||
<label className="label">Text Pipeline</label>
|
||||
<div className="control select">
|
||||
<select
|
||||
name="text_pipeline_type"
|
||||
onChange={handleTextPipelineChange}
|
||||
value={textPipelineType || "legacy_fakeyou"}
|
||||
>
|
||||
{Array.from(TEXT_PIPELINE_NAMES, ([textPipelineType, description]) => {
|
||||
return <option
|
||||
key={textPipelineType}
|
||||
value={textPipelineType}
|
||||
>{description}</option>
|
||||
})}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label className="label">Default vocoder</label>
|
||||
<div className="control select">
|
||||
|
||||
@@ -6,6 +6,7 @@ import { SessionWrapper } from '@storyteller/components/src/session/SessionWrapp
|
||||
import { Gravatar } from '@storyteller/components/src/elements/Gravatar';
|
||||
import { LanguageCodeToDescriptionWithDefault } from '@storyteller/components/src/i18n/SupportedModelLanguages';
|
||||
import { TtsInferenceJob } from '@storyteller/components/src/jobs/TtsInferenceJobs';
|
||||
import { TEXT_PIPELINE_NAMES } from '@storyteller/components/src/constants/TextPipeline';
|
||||
import { useParams, Link } from 'react-router-dom';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { FrontendUrlConfig } from '../../../../common/FrontendUrlConfig';
|
||||
@@ -372,6 +373,12 @@ function TtsModelViewFc(props: Props) {
|
||||
<><code>/tts {ttsModel?.maybe_suggested_unique_bot_command}</code></> :
|
||||
<>not set (ask a moderator in <DiscordLink text="Discord" />)</> ;
|
||||
|
||||
const textPipelineType = !!ttsModel.text_pipeline_type ?
|
||||
ttsModel.text_pipeline_type :
|
||||
ttsModel.text_pipeline_type_guess;
|
||||
|
||||
let textPipelineName = TEXT_PIPELINE_NAMES.get(textPipelineType) || "Unknown";
|
||||
|
||||
return (
|
||||
<div className="content">
|
||||
<h1 className="title is-1"> {title} </h1>
|
||||
@@ -418,8 +425,8 @@ function TtsModelViewFc(props: Props) {
|
||||
<td>{defaultVocoder}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Text preprocessing algorithm</th>
|
||||
<td>{ttsModel?.text_preprocessing_algorithm}</td>
|
||||
<th>Text pipeline</th>
|
||||
<td>{textPipelineName}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Upload date (UTC)</th>
|
||||
|
||||
Reference in new issue
Block a user