diff --git a/scripts/fetch_and_generate.ts b/scripts/fetch_and_generate.ts index ba69719..6aae1e3 100644 --- a/scripts/fetch_and_generate.ts +++ b/scripts/fetch_and_generate.ts @@ -82,9 +82,9 @@ async function main() { .createHash("md5") .update(category) .digest("hex"); - const uniqueFilename = `${feedUrlHash}-${categoryHash}.wav`; + const uniqueId = `${feedUrlHash}-${categoryHash}.wav`; - const audioFilePath = await generateTTS(uniqueFilename, podcastContent); + const audioFilePath = await generateTTS(uniqueId, podcastContent); console.log(`音声ファイル生成完了: ${audioFilePath}`); // エピソードとして保存(各フィードにつき1つの統合エピソード) @@ -96,7 +96,7 @@ async function main() { const pub = new Date(firstItem.pubDate || ""); await saveEpisode({ - id: `topic-${categoryHash}`, + id: uniqueId, title: `${category}: ${feedTitle}`, pubDate: pub.toISOString(), audioPath: audioFilePath, diff --git a/services/tts.ts b/services/tts.ts index 470748a..419e07f 100644 --- a/services/tts.ts +++ b/services/tts.ts @@ -63,7 +63,7 @@ export async function generateTTS( const filePath = path.resolve(outputDir, itemId); // Use the provided filename directly console.log(`音声ファイル保存開始: ${filePath}`); - fs.writeFileSync(filePath, audioBuffer); + fs.writeFileSync(`${filePath}.wav`, audioBuffer); console.log(`音声ファイル保存完了: ${filePath}`); return path.basename(filePath);