feat: enable podcast

This commit is contained in:
Li Xin
2025-04-19 22:11:57 +08:00
parent 4d33aeed6a
commit 2f06f0c433
7 changed files with 172 additions and 33 deletions

View File

@@ -0,0 +1,19 @@
// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
export async function generatePodcast(content: string) {
const response = await fetch("/api/podcast/generate", {
method: "post",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ content }),
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const arrayBuffer = await response.arrayBuffer();
const blob = new Blob([arrayBuffer], { type: "audio/mp3" });
const audioUrl = URL.createObjectURL(blob);
return audioUrl;
}