feat: add detailed logging for debugging and monitoring
This commit is contained in:
		@@ -68,8 +68,12 @@ async function main() {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const already = await markAsProcessed(url, finalItemId);
 | 
					        const already = await markAsProcessed(url, finalItemId);
 | 
				
			||||||
        if (already) continue;
 | 
					        if (already) {
 | 
				
			||||||
 | 
					          console.log(`既に処理済み: ${finalItemId}`);
 | 
				
			||||||
 | 
					          continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        console.log(`スクリプト生成開始: ${finalItemId}`);
 | 
				
			||||||
        const scriptText = await openAI_GenerateScript({
 | 
					        const scriptText = await openAI_GenerateScript({
 | 
				
			||||||
          title: item.title ?? "",
 | 
					          title: item.title ?? "",
 | 
				
			||||||
          link: item.link ?? "",
 | 
					          link: item.link ?? "",
 | 
				
			||||||
@@ -83,6 +87,8 @@ async function main() {
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        const audioFilePath = await generateTTS(uniqueFilename, scriptText);
 | 
					        const audioFilePath = await generateTTS(uniqueFilename, scriptText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        console.log(`音声ファイル生成完了: ${audioFilePath}`);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        await saveEpisode({
 | 
					        await saveEpisode({
 | 
				
			||||||
          id: finalItemId,
 | 
					          id: finalItemId,
 | 
				
			||||||
          title: item.title ?? "",
 | 
					          title: item.title ?? "",
 | 
				
			||||||
@@ -90,6 +96,8 @@ async function main() {
 | 
				
			|||||||
          audioPath: audioFilePath,
 | 
					          audioPath: audioFilePath,
 | 
				
			||||||
          sourceLink: item.link ?? "",
 | 
					          sourceLink: item.link ?? "",
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        console.log(`エピソード保存完了: ${finalItemId}`);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,6 +18,7 @@ export async function generateTTS(
 | 
				
			|||||||
  itemId: string,
 | 
					  itemId: string,
 | 
				
			||||||
  scriptText: string,
 | 
					  scriptText: string,
 | 
				
			||||||
): Promise<string> {
 | 
					): Promise<string> {
 | 
				
			||||||
 | 
					  console.log(`TTS生成開始: ${itemId}`);
 | 
				
			||||||
  const encodedText = encodeURIComponent(scriptText);
 | 
					  const encodedText = encodeURIComponent(scriptText);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const queryUrl = `${VOICEVOX_HOST}/audio_query?text=${encodedText}&speaker=${defaultVoiceStyle.styleId}`;
 | 
					  const queryUrl = `${VOICEVOX_HOST}/audio_query?text=${encodedText}&speaker=${defaultVoiceStyle.styleId}`;
 | 
				
			||||||
@@ -37,6 +38,7 @@ export async function generateTTS(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  const audioQuery = await queryResponse.json();
 | 
					  const audioQuery = await queryResponse.json();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  console.log(`音声合成開始: ${itemId}`);
 | 
				
			||||||
  const audioResponse = await fetch(synthesisUrl, {
 | 
					  const audioResponse = await fetch(synthesisUrl, {
 | 
				
			||||||
    method: "POST",
 | 
					    method: "POST",
 | 
				
			||||||
    headers: {
 | 
					    headers: {
 | 
				
			||||||
@@ -46,6 +48,7 @@ export async function generateTTS(
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (!audioResponse.ok) {
 | 
					  if (!audioResponse.ok) {
 | 
				
			||||||
 | 
					    console.error(`音声合成失敗: ${itemId}`);
 | 
				
			||||||
    throw new Error("VOICEVOX 音声合成に失敗しました");
 | 
					    throw new Error("VOICEVOX 音声合成に失敗しました");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -59,7 +62,9 @@ export async function generateTTS(
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const filePath = path.resolve(outputDir, itemId); // Use the provided filename directly
 | 
					  const filePath = path.resolve(outputDir, itemId); // Use the provided filename directly
 | 
				
			||||||
 | 
					  console.log(`音声ファイル保存開始: ${filePath}`);
 | 
				
			||||||
  fs.writeFileSync(filePath, audioBuffer);
 | 
					  fs.writeFileSync(filePath, audioBuffer);
 | 
				
			||||||
 | 
					  console.log(`音声ファイル保存完了: ${filePath}`);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return filePath;
 | 
					  return filePath;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user