🔀 refactor: Modularize TTS Logic for Improved Browser support (#3657)

* WIP: message audio refactor

* WIP: use MessageAudio by provider

* fix: Update MessageAudio component to use TTSEndpoints enum

* feat: Update useTextToSpeechBrowser hook to handle errors and improve error logging

* feat: Add voice dropdown components for different TTS engines

* docs: update incorrect `voices` example

changed `voice: ''` to `voices: ['alloy']`

* feat: Add brwoser support check for Edge TTS engine component with error toast if not supported

---------

Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com>
This commit is contained in:
Danny Avila 2024-08-15 11:34:25 -04:00 committed by GitHub
parent bcde0beb47
commit dba704079c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 784 additions and 187 deletions

View file

@ -19,6 +19,7 @@ import type {
TStartupConfig,
EModelEndpoint,
AssistantsEndpoint,
TMessageContentParts,
AuthorizationTypeEnum,
TSetOption as SetOption,
TokenExchangeMethodEnum,
@ -31,6 +32,17 @@ export enum PromptsEditorMode {
ADVANCED = 'advanced',
}
export enum STTEndpoints {
browser = 'browser',
external = 'external',
}
export enum TTSEndpoints {
browser = 'browser',
edge = 'edge',
external = 'external',
}
export type AudioChunk = {
audio: string;
isFinal: boolean;
@ -374,6 +386,19 @@ export type Option = Record<string, unknown> & {
value: string | number | null;
};
export type VoiceOption = {
value: string;
label: string;
};
export type TMessageAudio = {
messageId?: string;
content?: TMessageContentParts[] | string;
className?: string;
isLast: boolean;
index: number;
};
export type OptionWithIcon = Option & { icon?: React.ReactNode };
export type MentionOption = OptionWithIcon & {
type: string;