mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
housekeeping, code organization
This commit is contained in:
1 parent
924e9468be
commit
3dc154942e
6 files changed
+106
-56
No files matched your search
+11
@@ -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`;
|
||||
@@ -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
|
||||
}:{
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Types for Listing TTS Models
|
||||
*/
|
||||
|
||||
export interface TtsModelListResponsePayload {
|
||||
success: boolean,
|
||||
models: Array<TtsModelListItem>,
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -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<TtsModelListItem>,
|
||||
}
|
||||
|
||||
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<Array<TtsModelListItem>| undefined> {
|
||||
const endpoint = 'https://api.fakeyou.com/tts/list';
|
||||
|
||||
return await fetch(endpoint, {
|
||||
export async function ListTtsModels() : Promise<Array<TtsModelListItem>| undefined> {
|
||||
return await fetch(listTts, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
|
||||
Reference in new issue
Block a user