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