Skip to content

Commit

Permalink
support tts format
Browse files Browse the repository at this point in the history
  • Loading branch information
heimoshuiyu committed Nov 30, 2023
1 parent 97a75ce commit 92252f6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface ChatStore {
tts_voice: string;
tts_speed: number;
tts_speed_enabled: boolean;
tts_format: string;
image_gen_api: string;
image_gen_key: string;
json_mode: boolean;
Expand All @@ -79,6 +80,7 @@ export const newChatStore = (
tts_key = "",
tts_speed = 1.0,
tts_speed_enabled = false,
tts_format = "mp3",
toolsString = "",
image_gen_api = "https://api.openai.com/v1/images/generations",
image_gen_key = "",
Expand Down Expand Up @@ -118,6 +120,7 @@ export const newChatStore = (
image_gen_api: image_gen_api,
image_gen_key: image_gen_key,
json_mode: json_mode,
tts_format: tts_format,
};
};

Expand Down Expand Up @@ -275,6 +278,7 @@ export function App() {
chatStore.tts_key,
chatStore.tts_speed,
chatStore.tts_speed_enabled,
chatStore.tts_format,
chatStore.toolsString,
chatStore.image_gen_api,
chatStore.image_gen_key,
Expand Down
17 changes: 17 additions & 0 deletions src/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const TTS_VOICES: string[] = [
"nova",
"shimmer",
];
const TTS_FORMAT: string[] = ["mp3", "opus", "aac", "flac"];

const Help = (props: { children: any; help: string }) => {
return (
Expand Down Expand Up @@ -510,6 +511,22 @@ export default (props: {
help={"TTS Speed"}
{...props}
/>
<Help help="tts response format">
<label className="m-2 p-2">TTS Format</label>
<select
className="m-2 p-2"
value={props.chatStore.tts_format}
onChange={(event: any) => {
const format = event.target.value as string;
props.chatStore.tts_format = format;
props.setChatStore({ ...props.chatStore });
}}
>
{TTS_FORMAT.map((opt) => (
<option value={opt}>{opt}</option>
))}
</select>
</Help>
<Input
field="image_gen_key"
help="image generation service api key"
Expand Down
2 changes: 1 addition & 1 deletion src/tts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function TTSButton(props: TTSProps) {
model,
input,
voice,
response_format: "opus",
response_format: props.chatStore.tts_format || "mp3",
};
if (props.chatStore.tts_speed_enabled) {
body["speed"] = props.chatStore.tts_speed;
Expand Down

0 comments on commit 92252f6

Please sign in to comment.