From a355d4c1e48e69c112c740ff5b497b07fe159d85 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Fri, 11 Feb 2022 08:18:27 -0500 Subject: [PATCH] Nicer TTS Inference Results (text, title, styling) --- packages/components/src/api/ApiConfig.ts | 4 +- packages/components/src/api/BucketConfig.ts | 2 +- .../src/api/jobs/GetTtsInferenceJobStatus.ts | 2 + .../components/src/jobs/TtsInferenceJobs.ts | 9 +++- .../SessionTtsInferenceResultsListFc.tsx | 53 ++++++++++++++----- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/packages/components/src/api/ApiConfig.ts b/packages/components/src/api/ApiConfig.ts index 366f2e1d01..7599270b08 100644 --- a/packages/components/src/api/ApiConfig.ts +++ b/packages/components/src/api/ApiConfig.ts @@ -343,8 +343,8 @@ class ApiConfig { } obsEventsWebsocket(twitchUsername: string) : string { - //return `ws://localhost:54321/obs/${twitchUsername}`; - return `wss://obs.storyteller.io/obs/${twitchUsername}`; + return `ws://localhost:54321/obs/${twitchUsername}`; + //return `wss://obs.storyteller.io/obs/${twitchUsername}`; } private getScheme() : string { diff --git a/packages/components/src/api/BucketConfig.ts b/packages/components/src/api/BucketConfig.ts index a2c6dc02b9..14fc348537 100644 --- a/packages/components/src/api/BucketConfig.ts +++ b/packages/components/src/api/BucketConfig.ts @@ -11,7 +11,7 @@ class BucketConfig { this.isLocalDev = false; } // TODO TEMP - this.isLocalDev = false; + //this.isLocalDev = false; } // TODO: Prevent callers with undefined/null paths diff --git a/packages/components/src/api/jobs/GetTtsInferenceJobStatus.ts b/packages/components/src/api/jobs/GetTtsInferenceJobStatus.ts index f73372509e..068469cf0f 100644 --- a/packages/components/src/api/jobs/GetTtsInferenceJobStatus.ts +++ b/packages/components/src/api/jobs/GetTtsInferenceJobStatus.ts @@ -26,6 +26,8 @@ export interface TtsInferenceJobStatus { tts_model_type: string, title: string, + raw_inference_text: string, + created_at: Date, updated_at: Date, } diff --git a/packages/components/src/jobs/TtsInferenceJobs.ts b/packages/components/src/jobs/TtsInferenceJobs.ts index 8448c89c63..906de1f68c 100644 --- a/packages/components/src/jobs/TtsInferenceJobs.ts +++ b/packages/components/src/jobs/TtsInferenceJobs.ts @@ -1,13 +1,16 @@ import { TtsInferenceJobStatus } from "../api/jobs/GetTtsInferenceJobStatus"; import { JobState, jobStateFromString } from "./JobStates"; +// NB: Many of these fields are optional despite the response payload containing them +// This is because we create temporary placeholder objects with just the token. export class TtsInferenceJob { jobToken: string; modelToken?: string; jobState: JobState; maybeExtraStatusDescription: string | null; attemptCount: number; - title?: string; + title?: string; // Name of the TTS model + rawInferenceText?: string; maybeResultToken: string | undefined | null; maybePublicBucketWavAudioPath: string | undefined | null; @@ -18,6 +21,7 @@ export class TtsInferenceJob { attemptCount: number = 0, modelToken: string | undefined = undefined, title: string | undefined = undefined, + rawInferenceText: string | undefined = undefined, maybeResulToken: string | undefined | null = null, maybePublicBucketWavAudioPath: string | undefined | null = null, ) { @@ -32,6 +36,7 @@ export class TtsInferenceJob { if (!!title) { this.title = title; } + this.rawInferenceText = rawInferenceText; this.maybePublicBucketWavAudioPath = maybePublicBucketWavAudioPath; } @@ -43,6 +48,7 @@ export class TtsInferenceJob { response.attempt_count || 0, response.model_token, response.title, + response.raw_inference_text, response.maybe_result_token || null, response.maybe_public_bucket_wav_audio_path || null, ); @@ -64,6 +70,7 @@ export interface TtsInferenceJobState { model_token: string, tts_model_type: string, title: string, + raw_inference_text: string, created_at: string, updated_at: string, } diff --git a/packages/fakeyou/src/v2/view/_common/SessionTtsInferenceResultsListFc.tsx b/packages/fakeyou/src/v2/view/_common/SessionTtsInferenceResultsListFc.tsx index d5898f8837..bfd38a8993 100644 --- a/packages/fakeyou/src/v2/view/_common/SessionTtsInferenceResultsListFc.tsx +++ b/packages/fakeyou/src/v2/view/_common/SessionTtsInferenceResultsListFc.tsx @@ -15,6 +15,7 @@ function SessionTtsInferenceResultListFc(props: Props) { props.ttsInferenceJobs.forEach(job => { if (!job.maybeResultToken) { + let cssStyle = "message"; let stateDescription = "Pending..."; switch (job.jobState) { @@ -23,39 +24,65 @@ function SessionTtsInferenceResultListFc(props: Props) { stateDescription = job.maybeExtraStatusDescription == null ? "Pending..." : job.maybeExtraStatusDescription; break; case JobState.STARTED: + cssStyle = "message is-primary"; stateDescription = job.maybeExtraStatusDescription == null ? "Started..." : job.maybeExtraStatusDescription; break; case JobState.ATTEMPT_FAILED: + cssStyle = "message is-warning"; stateDescription = `Failed ${job.attemptCount} attempt(s). Will retry...`; break; case JobState.COMPLETE_FAILURE: case JobState.DEAD: + cssStyle = "message is-danger"; stateDescription = "Failed Permanently. Please tell us in Discord so we can fix. :("; break; case JobState.COMPLETE_SUCCESS: + cssStyle = "message is-success"; stateDescription = "Success!"; // Not sure why we're here instead of other branch! break; } results.push( -
{stateDescription}
+
+
+
+

+ {stateDescription} +

+
+
+   +
); } else { let audioLink = new BucketConfig().getGcsUrl(job.maybePublicBucketWavAudioPath); let ttsPermalink = `/tts/result/${job.maybeResultToken}` results.push(
- +
+ {/*
+

{job.title}

+ +
*/} +
+ {job.title} +

{job.rawInferenceText}

- Permalink & download + +   + + Permalink & download +
+
+  
); } @@ -70,6 +97,9 @@ function SessionTtsInferenceResultListFc(props: Props) { title =

Session TTS Results

; } + // Users have requested reverse chronological results + results.reverse(); + return (
{title} @@ -79,7 +109,6 @@ function SessionTtsInferenceResultListFc(props: Props) { Sorry this is slow. I'm scaling the cluster and fixing the caching strategy.

*/} -
{results} );