fix: fix template literal errors in llm, podcast, and tts services
This commit is contained in:
		@@ -10,15 +10,15 @@ export async function openAI_GenerateScript(item: {
 | 
			
		||||
  link: string;
 | 
			
		||||
  contentSnippet?: string;
 | 
			
		||||
}): Promise<string> {
 | 
			
		||||
  const prompt = \`
 | 
			
		||||
  const prompt = `
 | 
			
		||||
あなたはポッドキャスターです。以下の情報をもとに、リスナー向けにわかりやすい日本語のポッドキャスト原稿を書いてください。
 | 
			
		||||
 | 
			
		||||
- 記事タイトル: \${item.title}
 | 
			
		||||
- 記事リンク: \${item.link}
 | 
			
		||||
- 記事概要: \${item.contentSnippet || "なし"}
 | 
			
		||||
- 記事タイトル: ${item.title}
 | 
			
		||||
- 記事リンク: ${item.link}
 | 
			
		||||
- 記事概要: ${item.contentSnippet || "なし"}
 | 
			
		||||
 | 
			
		||||
「今日のニュース記事をご紹介します…」といった導入も含め、約300文字程度でまとめてください。
 | 
			
		||||
\`;
 | 
			
		||||
`;
 | 
			
		||||
  const response = await openai.createChatCompletion({
 | 
			
		||||
    model: "gpt-4o-mini",
 | 
			
		||||
    messages: [{ role: "user", content: prompt.trim() }],
 | 
			
		||||
 
 | 
			
		||||
@@ -16,28 +16,28 @@ export async function updatePodcastRSS() {
 | 
			
		||||
      ep.audioPath
 | 
			
		||||
    )}`;
 | 
			
		||||
    const pubDate = new Date(ep.pubDate).toUTCString();
 | 
			
		||||
    itemsXml += \`
 | 
			
		||||
    itemsXml += `
 | 
			
		||||
      <item>
 | 
			
		||||
        <title><![CDATA[\${ep.title}]]></title>
 | 
			
		||||
        <title><![CDATA[${ep.title}]]></title>
 | 
			
		||||
        <description><![CDATA[この記事を元に自動生成したポッドキャストです]]></description>
 | 
			
		||||
        <enclosure url="\${fileUrl}" length="\${fs.statSync(ep.audioPath).size}" type="audio/mpeg" />
 | 
			
		||||
        <guid>\${fileUrl}</guid>
 | 
			
		||||
        <pubDate>\${pubDate}</pubDate>
 | 
			
		||||
        <enclosure url="${fileUrl}" length="${fs.statSync(ep.audioPath).size}" type="audio/mpeg" />
 | 
			
		||||
        <guid>${fileUrl}</guid>
 | 
			
		||||
        <pubDate>${pubDate}</pubDate>
 | 
			
		||||
      </item>
 | 
			
		||||
    \`;
 | 
			
		||||
    `;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const rssXml = \`<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
  const rssXml = `<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
  <rss version="2.0">
 | 
			
		||||
    <channel>
 | 
			
		||||
      <title><![CDATA[\${channelTitle}]]></title>
 | 
			
		||||
      <link>\${channelLink}</link>
 | 
			
		||||
      <description><![CDATA[\${channelDescription}]]></description>
 | 
			
		||||
      <lastBuildDate>\${lastBuildDate}</lastBuildDate>
 | 
			
		||||
      \${itemsXml}
 | 
			
		||||
      <title><![CDATA[${channelTitle}]]></title>
 | 
			
		||||
      <link>${channelLink}</link>
 | 
			
		||||
      <description><![CDATA[${channelDescription}]]></description>
 | 
			
		||||
      <lastBuildDate>${lastBuildDate}</lastBuildDate>
 | 
			
		||||
      ${itemsXml}
 | 
			
		||||
    </channel>
 | 
			
		||||
  </rss>
 | 
			
		||||
  \`;
 | 
			
		||||
  `;
 | 
			
		||||
 | 
			
		||||
  const outputPath = path.join(__dirname, "../public/podcast.xml");
 | 
			
		||||
  fs.writeFileSync(outputPath, rssXml.trim());
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ export async function generateTTS(
 | 
			
		||||
  if (!fs.existsSync(outputDir)) {
 | 
			
		||||
    fs.mkdirSync(outputDir, { recursive: true });
 | 
			
		||||
  }
 | 
			
		||||
  const filePath = path.join(outputDir, \`\${itemId}.mp3\`);
 | 
			
		||||
  const filePath = path.join(outputDir, `${itemId}.mp3`);
 | 
			
		||||
 | 
			
		||||
  const chunks: Uint8Array[] = [];
 | 
			
		||||
  for await (const chunk of response.AudioStream as any) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user