mirror of
https://github.com/baptisteArno/typebot.io.git
synced 2026-06-19 21:04:33 +08:00
🚸 Gracefully handle and display createSpeech error
This commit is contained in:
parent
b4ce205f70
commit
49e246a7ac
@ -103,19 +103,27 @@ export const createSpeech = createAction({
|
||||
|
||||
const model = options.model ?? defaultOpenAIOptions.voiceModel;
|
||||
|
||||
const rawAudio = (await openai.audio.speech.create({
|
||||
input: options.input,
|
||||
voice: options.voice,
|
||||
model,
|
||||
})) as any;
|
||||
try {
|
||||
const rawAudio = (await openai.audio.speech.create({
|
||||
input: options.input,
|
||||
voice: options.voice,
|
||||
model,
|
||||
})) as any;
|
||||
const url = await uploadFileToBucket({
|
||||
file: Buffer.from((await rawAudio.arrayBuffer()) as ArrayBuffer),
|
||||
key: `tmp/openai/audio/${createId() + createId()}.mp3`,
|
||||
mimeType: "audio/mpeg",
|
||||
});
|
||||
|
||||
const url = await uploadFileToBucket({
|
||||
file: Buffer.from((await rawAudio.arrayBuffer()) as ArrayBuffer),
|
||||
key: `tmp/openai/audio/${createId() + createId()}.mp3`,
|
||||
mimeType: "audio/mpeg",
|
||||
});
|
||||
|
||||
variables.set([{ id: options.saveUrlInVariableId, value: url }]);
|
||||
variables.set([{ id: options.saveUrlInVariableId, value: url }]);
|
||||
} catch (err) {
|
||||
logs.add(
|
||||
await parseUnknownError({
|
||||
err,
|
||||
context: "While generating speech",
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user