Files
deer-flow/web/src/core/api/podcast.ts
2025-04-24 15:41:33 +08:00

22 lines
681 B
TypeScript

// Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
// SPDX-License-Identifier: MIT
import { resolveServiceURL } from "./resolve-service-url";
export async function generatePodcast(content: string) {
const response = await fetch(resolveServiceURL("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;
}