Fix timeout for TTS service
This commit is contained in:
@ -41,7 +41,9 @@ export async function generateTTS(
|
|||||||
|
|
||||||
if (!queryResponse.ok) {
|
if (!queryResponse.ok) {
|
||||||
const errorText = await queryResponse.text();
|
const errorText = await queryResponse.text();
|
||||||
throw new Error(`VOICEVOX audio query failed (${queryResponse.status}): ${errorText}`);
|
throw new Error(
|
||||||
|
`VOICEVOX audio query failed (${queryResponse.status}): ${errorText}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const audioQuery = await queryResponse.json();
|
const audioQuery = await queryResponse.json();
|
||||||
@ -53,12 +55,15 @@ export async function generateTTS(
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(audioQuery),
|
body: JSON.stringify(audioQuery),
|
||||||
|
signal: AbortSignal.timeout(10000000), // タイムアウトを10分に設定
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!audioResponse.ok) {
|
if (!audioResponse.ok) {
|
||||||
const errorText = await audioResponse.text();
|
const errorText = await audioResponse.text();
|
||||||
console.error(`音声合成失敗: ${itemId}`);
|
console.error(`音声合成失敗: ${itemId}`);
|
||||||
throw new Error(`VOICEVOX synthesis failed (${audioResponse.status}): ${errorText}`);
|
throw new Error(
|
||||||
|
`VOICEVOX synthesis failed (${audioResponse.status}): ${errorText}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const audioArrayBuffer = await audioResponse.arrayBuffer();
|
const audioArrayBuffer = await audioResponse.arrayBuffer();
|
||||||
@ -95,7 +100,9 @@ export async function generateTTS(
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (result.exitCode !== 0) {
|
if (result.exitCode !== 0) {
|
||||||
const stderr = result.stderr ? new TextDecoder().decode(result.stderr) : "Unknown error";
|
const stderr = result.stderr
|
||||||
|
? new TextDecoder().decode(result.stderr)
|
||||||
|
: "Unknown error";
|
||||||
throw new Error(`FFmpeg conversion failed: ${stderr}`);
|
throw new Error(`FFmpeg conversion failed: ${stderr}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +116,8 @@ export async function generateTTS(
|
|||||||
return path.basename(mp3FilePath);
|
return path.basename(mp3FilePath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error generating TTS:", error);
|
console.error("Error generating TTS:", error);
|
||||||
throw new Error(`Failed to generate TTS: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
throw new Error(
|
||||||
|
`Failed to generate TTS: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user