diff --git a/app/api.tsx b/app/api.tsx new file mode 100644 index 0000000000..666b25afbb --- /dev/null +++ b/app/api.tsx @@ -0,0 +1,11 @@ +export const apiHost = 'https://api.fakeyou.com'; + +// Authentications +// const createAccount = `${apiHost}}/create_account`; +export const login = `${apiHost}/v1/login`; +export const getSession = `${apiHost}/v1/session`; +export const logout = `${apiHost}/v1/logout`; + +// TTS +export const inferTts = `${apiHost}/tts/inference`; +export const listTts = `${apiHost}/tts/list`; \ No newline at end of file diff --git a/app/contexts/Authentication/utilities.tsx b/app/contexts/Authentication/utilities.tsx index ccd7915e30..0cc54b8f46 100644 --- a/app/contexts/Authentication/utilities.tsx +++ b/app/contexts/Authentication/utilities.tsx @@ -1,14 +1,8 @@ - +import { login, getSession, logout } from '~/api'; import { SessionResponse, } from "./types"; -const apiHost = "https://api.fakeyou.com"; -// const createAccount = `${apiHost}}/create_account`; -const login = `${apiHost}/v1/login`; -const getSession = `${apiHost}/v1/session`; -const logout = `${apiHost}/v1/logout`; - export const CreateSession = async ({ usernameOrEmail, password }:{ diff --git a/app/pages/PageEnigma/comps/ControlsTopButtons/TestFeaturesButtons.tsx b/app/pages/PageEnigma/comps/ControlsTopButtons/TestFeaturesButtons.tsx index 2a5376de50..19c84a06a1 100644 --- a/app/pages/PageEnigma/comps/ControlsTopButtons/TestFeaturesButtons.tsx +++ b/app/pages/PageEnigma/comps/ControlsTopButtons/TestFeaturesButtons.tsx @@ -1,4 +1,4 @@ -import { useContext, useState } from "react"; +import { useContext } from "react"; import { Button, } from "~/components"; import { ClipGroup } from "~/pages/PageEnigma/models/track"; import { APPUI_ACTION_TYPES } from "../../reducers"; diff --git a/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx b/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx index bf597f016d..1936ac16c5 100644 --- a/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx +++ b/app/pages/PageEnigma/comps/DialogueTTS/DialogueTTS.tsx @@ -11,16 +11,17 @@ import { TransitionDialogue, Textarea } from "~/components"; -import { ListTtsModels, TtsModelListItem } from "./utilities"; +import { ListTtsModels } from "./utilities"; +import { TtsModelListItem } from "./types"; -const testdata = [ - { name: 'Wade Cooper' }, - { name: 'Arlene Mccoy' }, - { name: 'Devon Webb' }, - { name: 'Tom Cook' }, - { name: 'Tanya Fox' }, - { name: 'Hellen Schmidt' }, -] +// const testdata = [ +// { name: 'Wade Cooper' }, +// { name: 'Arlene Mccoy' }, +// { name: 'Devon Webb' }, +// { name: 'Tom Cook' }, +// { name: 'Tanya Fox' }, +// { name: 'Hellen Schmidt' }, +// ] type TtsState = { voice: string; text: string; @@ -52,9 +53,17 @@ export const DialogueTTS = ()=>{ listModels(); }, [listModels]); - // useEffect(() => { - // console.log(ttsModels); - // }, [ttsModels]); + const requestTts = useCallback(()=>{ + // const modelToken = props.maybeSelectedTtsModel!.model_token; + + // const request = { + // uuid_idempotency_token: uuidv4(), + // tts_model_token: modelToken, + // inference_text: props.textBuffer, + // }; + + // const response = await GenerateTtsAudio(request); + },[]); const handleClose = ()=> { dispatchAppUiState({ diff --git a/app/pages/PageEnigma/comps/DialogueTTS/types.tsx b/app/pages/PageEnigma/comps/DialogueTTS/types.tsx new file mode 100644 index 0000000000..76ebee3837 --- /dev/null +++ b/app/pages/PageEnigma/comps/DialogueTTS/types.tsx @@ -0,0 +1,65 @@ +/* + * Types for Listing TTS Models + */ + +export interface TtsModelListResponsePayload { + success: boolean, + models: Array, +} + +export interface UserRatings { + positive_count: number, + negative_count: number, + // Total count does not take into account "neutral" ratings. + total_count: number, +} + +export interface TtsModelListItem { + model_token: string, + tts_model_type: string, + creator_user_token: string, + creator_username: string, + creator_display_name: string, + creator_gravatar_hash: string, + ietf_language_tag: string, + ietf_primary_language_subtag: string, + updatable_slug: string, + title: string, + is_front_page_featured: boolean, + is_twitch_featured: boolean, + user_ratings: UserRatings, + category_tokens: string[], + created_at: string, + updated_at: string, +} + +/* + * Types for Making a TTS Generation Request + */ +export interface GenerateTtsAudioRequest { + uuid_idempotency_token: string, + tts_model_token: string, + inference_text: string, + // TODO(2022-03): TEMPORARY + is_storyteller_demo?: boolean, +} + +export interface GenerateTtsAudioSuccess { + success: boolean, + inference_job_token: string, + // Which queue to poll + inference_job_token_type?: string, +} + +export interface GenerateTtsAudioError { + error: GenerateTtsAudioErrorType, +} + +export enum GenerateTtsAudioErrorType { + BadRequest, + NotFound, + TooManyRequests, + ServerError, + UnknownError, +} +export type GenerateTtsAudioResponse = GenerateTtsAudioSuccess | GenerateTtsAudioError; \ No newline at end of file diff --git a/app/pages/PageEnigma/comps/DialogueTTS/utilities.tsx b/app/pages/PageEnigma/comps/DialogueTTS/utilities.tsx index cb2b6bf037..7084dc91ef 100644 --- a/app/pages/PageEnigma/comps/DialogueTTS/utilities.tsx +++ b/app/pages/PageEnigma/comps/DialogueTTS/utilities.tsx @@ -1,40 +1,11 @@ -// https://api.fakeyou.com/tts/list +import { listTts } from '~/api'; +import { + TtsModelListItem, + TtsModelListResponsePayload +} from './types'; -interface TtsModelListResponsePayload { - success: boolean, - models: Array, -} - -export interface UserRatings { - positive_count: number, - negative_count: number, - // Total count does not take into account "neutral" ratings. - total_count: number, -} - -export interface TtsModelListItem { - model_token: string, - tts_model_type: string, - creator_user_token: string, - creator_username: string, - creator_display_name: string, - creator_gravatar_hash: string, - ietf_language_tag: string, - ietf_primary_language_subtag: string, - updatable_slug: string, - title: string, - is_front_page_featured: boolean, - is_twitch_featured: boolean, - user_ratings: UserRatings, - category_tokens: string[], - created_at: string, - updated_at: string, -} - -export async function ListTtsModels() : Promise| undefined> { - const endpoint = 'https://api.fakeyou.com/tts/list'; - - return await fetch(endpoint, { +export async function ListTtsModels() : Promise| undefined> { + return await fetch(listTts, { method: 'GET', headers: { 'Accept': 'application/json',