mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-09-18 01:17:09 +08:00
feat: #3110 add voice control
This commit is contained in:
@@ -303,5 +303,28 @@ export class ChatGPTApi implements LLMApi {
|
||||
available: true,
|
||||
}));
|
||||
}
|
||||
|
||||
public cache: Record<string, ArrayBuffer> = {};
|
||||
|
||||
async speech(input: string): Promise<ArrayBuffer> {
|
||||
if (this.cache[input]) return this.cache[input].slice(0);
|
||||
|
||||
const res = await fetch(this.path(OpenaiPath.Speech), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
...getHeaders(),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
model: "tts-1",
|
||||
input: input,
|
||||
voice: "onyx",
|
||||
}),
|
||||
});
|
||||
|
||||
const arrayBuffer = await res.arrayBuffer();
|
||||
this.cache[input] = arrayBuffer.slice(0);
|
||||
return arrayBuffer;
|
||||
}
|
||||
}
|
||||
|
||||
export { OpenaiPath };
|
||||
|
Reference in New Issue
Block a user