i have created a project where user enter the youtube link and the ai gives the the a summary of that video using youtbe transcript.
I had run it in local server and it was running perfecty but when i put it in to prodution it is not working.
import { YoutubeTranscript } from 'youtube-transcript';import { GoogleGenerativeAI } from "@google/generative-ai";const genAI = new GoogleGenerativeAI(process.env.Gemini_Key);const model = await genAI.getGenerativeModel({ model: "gemini-1.5-flash" });const chat = await model.startChat({ history: [] });export const summarizeTranscript = async (req, res) => {// const { Youtube_Url } = await request.json(); const { Youtube_Url } = req.body; const prompt = "Summarize this YouTube transcript in less than 50 words."; try { const transcript = await YoutubeTranscript.fetchTranscript(Youtube_Url); let newTranscript = ''; for (let i = 0; i < transcript.length; i++) { newTranscript += `Timestamp: ${transcript[i].offset}, Text: ${transcript[i].text}\n`; } // return NextResponse.json({ transcript: newTranscript }); const result = await chat.sendMessage([prompt, newTranscript]) res.json({response: result.response.text()}); } catch (error) { console.error('Error fetching transcript:', error); // return NextResponse.json( // { error: 'Failed to fetch video transcript. Please check the URL and try again.' }, // { status: 500 } // ); }}
I have tried different codes, changing library and some different codes i it has not work.