Feat/tts stt voices languages from api server (#376)

* support fetching tts/stt language and voice from api server

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip
This commit is contained in:
Hoan Luu Huu authored and GitHub committed 2024-01-12 07:34:22 -05:00
1 parent 353c7cfff8
commit 8b9c7ca9c0
30 files changed
+427 -11745

No files matched your search

+17 -30
View File
@@ -91,12 +91,9 @@ import type {
DeleteAccount,
ChangePassword,
SignIn,
GetVoices,
LanguageOption,
VoiceOption,
GetLanguages,
GoogleCustomVoice,
GoogleCustomVoicesQuery,
SpeechSupportedLanguagesAndVoices,
} from "./types";
import { Availability, StatusCodes } from "./types";
import { JaegerRoot } from "./jaeger-types";
@@ -336,32 +333,6 @@ export const postSpeechService = (
return postFetch<SidResponse, Partial<SpeechCredential>>(apiUrl, payload);
};
export const postSpeechServiceVoices = (
sid: string,
payload: Partial<GetVoices>
) => {
const userData = parseJwt(getToken());
const apiUrl =
userData.scope === USER_ACCOUNT
? `${API_ACCOUNTS}/${userData.account_sid}/SpeechCredentials/voices`
: `${API_SERVICE_PROVIDERS}/${sid}/SpeechCredentials/voices`;
return postFetch<VoiceOption[], Partial<GetVoices>>(apiUrl, payload);
};
export const postSpeechServiceLanguages = (
sid: string,
payload: Partial<GetLanguages>
) => {
const userData = parseJwt(getToken());
const apiUrl =
userData.scope === USER_ACCOUNT
? `${API_ACCOUNTS}/${userData.account_sid}/SpeechCredentials/languages`
: `${API_SERVICE_PROVIDERS}/${sid}/SpeechCredentials/languages`;
return postFetch<LanguageOption[], Partial<GetLanguages>>(apiUrl, payload);
};
export const postMsTeamsTentant = (payload: Partial<MSTeamsTenant>) => {
return postFetch<SidResponse, Partial<MSTeamsTenant>>(
API_MS_TEAMS_TENANTS,
@@ -900,6 +871,22 @@ export const getPrice = () => {
return getFetch<PriceInfo[]>(API_PRICE);
};
export const getSpeechSupportedLanguagesAndVoices = (
sid: string | undefined,
vendor: string,
label: string
) => {
const userData = parseJwt(getToken());
const apiUrl =
(userData.scope === USER_ACCOUNT
? `${API_ACCOUNTS}/${userData.account_sid}`
: `${API_SERVICE_PROVIDERS}/${sid}`) +
`/SpeechCredentials/speech/supportedLanguagesAndVoices?vendor=${vendor}${
label ? `&label=${label}` : ""
}`;
return getFetch<SpeechSupportedLanguagesAndVoices>(apiUrl);
};
/** Hooks for components to fetch data with refetch method */
/** :GET /{apiPath} -- this is generic for any fetch of data collections */
+6 -12
View File
@@ -1,4 +1,4 @@
import type { Vendor } from "src/vendor/types";
import type { Language, Model, Vendor, VoiceLanguage } from "src/vendor/types";
/** Simple types */
@@ -697,21 +697,15 @@ export interface SignIn {
account_sid?: null | string;
}
export interface GetVoices {
export interface GetLanguagesAndVoices {
vendor: string;
label: string;
}
export interface VoiceOption extends SelectorOptions {
[key: string]: unknown;
}
export interface GetLanguages extends GetVoices {
[key: string]: unknown;
}
export interface LanguageOption extends SelectorOptions {
[key: string]: unknown;
export interface SpeechSupportedLanguagesAndVoices {
tts: VoiceLanguage[];
stt: Language[];
models: Model[];
}
export interface ElevenLabsOptions {