Skip to content

feat: add Text-to-Speech (speaker) button to read chatbot responses aloud #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ You can also customize chatbot with different configuration
observeLoading: (loading) => {
console.log({ loading });
},
// It is only applicable if feedback is enabled
ttsConfig: {
language: 'en-US', // ISO code, e.g., 'en-US'
voice: 'Google UK English Male', // Specific voice name, e.g., 'Google UK English Male'
rate: 1, // Speed of speech: 0.1 - 10 (default is 1)
pitch: 1, // Pitch of voice: 0 - 2 (default is 1)
volume: 1, // Volume: 0 - 1 (default is 1)
},
theme: {
button: {
Expand Down
8 changes: 8 additions & 0 deletions dist/components/Bot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ export type MessageType = {
};
type observerConfigType = (accessor: string | boolean | object | MessageType[]) => void;
export type observersConfigType = Record<'observeUserInput' | 'observeLoading' | 'observeMessages', observerConfigType>;
export type ttsConfigType = {
language?: string;
voice?: string;
rate?: number;
pitch?: number;
volume?: number;
};
export type BotProps = {
chatflowid: string;
apiHost?: string;
Expand Down Expand Up @@ -109,6 +116,7 @@ export type BotProps = {
footer?: FooterTheme;
sourceDocsTitle?: string;
observersConfig?: observersConfigType;
ttsConfig?: ttsConfigType;
starterPrompts?: string[] | Record<string, {
prompt: string;
}>;
Expand Down
2 changes: 1 addition & 1 deletion dist/components/Bot.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dist/components/bubbles/BotBubble.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IAction, MessageType } from '../Bot';
import { IAction, MessageType, ttsConfigType } from '../Bot';
import { DateTimeToggleTheme } from '@/features/bubble/types';
type Props = {
message: MessageType;
Expand All @@ -19,6 +19,7 @@ type Props = {
showAgentMessages?: boolean;
sourceDocsTitle?: string;
renderHTML?: boolean;
ttsConfig?: ttsConfigType;
handleActionClick: (elem: any, action: IAction | undefined | null) => void;
handleSourceDocumentsClick: (src: any) => void;
};
Expand Down
2 changes: 1 addition & 1 deletion dist/components/bubbles/BotBubble.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/components/buttons/FeedbackButtons.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ type RatingButtonProps = {
export declare const CopyToClipboardButton: (props: RatingButtonProps) => JSX.Element;
export declare const ThumbsUpButton: (props: RatingButtonProps) => JSX.Element;
export declare const ThumbsDownButton: (props: RatingButtonProps) => JSX.Element;
type TTSButtonProps = {
isPlaying?: boolean;
} & RatingButtonProps;
export declare const TTSButton: (props: TTSButtonProps) => JSX.Element;
export {};
//# sourceMappingURL=FeedbackButtons.d.ts.map
2 changes: 1 addition & 1 deletion dist/components/buttons/FeedbackButtons.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/components/icons/CheckIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { JSX } from 'solid-js/jsx-runtime';
export declare const CheckIcon: (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element;
//# sourceMappingURL=CheckIcon.d.ts.map
1 change: 1 addition & 0 deletions dist/components/icons/CheckIcon.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/components/icons/PauseIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { JSX } from 'solid-js/jsx-runtime';
export declare const PauseIcon: (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element;
//# sourceMappingURL=PauseIcon.d.ts.map
1 change: 1 addition & 0 deletions dist/components/icons/PauseIcon.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/components/icons/PlayIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { JSX } from 'solid-js/jsx-runtime';
export declare const PlayIcon: (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element;
//# sourceMappingURL=PlayIcon.d.ts.map
1 change: 1 addition & 0 deletions dist/components/icons/PlayIcon.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/components/icons/VolumeIcon.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { JSX } from 'solid-js/jsx-runtime';
export declare const VolumeIcon: (props: JSX.SvgSVGAttributes<SVGSVGElement>) => JSX.Element;
//# sourceMappingURL=VolumeIcon.d.ts.map
1 change: 1 addition & 0 deletions dist/components/icons/VolumeIcon.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/components/icons/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ export * from './XIcon';
export * from './TickIcon';
export * from './AttachmentIcon';
export * from './SparklesIcon';
export * from './PauseIcon';
export * from './PlayIcon';
//# sourceMappingURL=index.d.ts.map
2 changes: 1 addition & 1 deletion dist/components/icons/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/constants.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/features/bubble/components/Bubble.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/features/full/components/Full.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/web.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/web.umd.js

Large diffs are not rendered by default.

Loading