From c934f45726327242abcc92a67015cbee614db754 Mon Sep 17 00:00:00 2001 From: Kar Date: Mon, 18 Nov 2024 19:14:04 +0530 Subject: [PATCH] aiTextToSpeech working without folder and s3 bucket manipulation --- src/routes/api/aiTextToSpeech.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/routes/api/aiTextToSpeech.js b/src/routes/api/aiTextToSpeech.js index b182af0..25c77a4 100644 --- a/src/routes/api/aiTextToSpeech.js +++ b/src/routes/api/aiTextToSpeech.js @@ -37,7 +37,6 @@ const aiTextToSpeech = async (req, res) => { }; try { - // Generate a folder name based on current timestamp and random digits function generateTimestampWithRandomDigits() { const now = new Date(); const formattedDate = now.toISOString().replace('T', '_').replace(/\..+/, '').replace(/:/g, '-'); @@ -48,21 +47,17 @@ const aiTextToSpeech = async (req, res) => { const folder = generateTimestampWithRandomDigits(); const folderName = `audio_files/${folder}`; - // Request Polly to synthesize speech const data = await polly.synthesizeSpeech(params).promise(); const audioBuffer = data.AudioStream; - // Prepare the text file as a buffer const textBuffer = Buffer.from(text, 'utf-8'); - // Prepare the form data to send via POST request const formData = new FormData(); formData.append('file1', audioBuffer, 'speech.mp3'); formData.append('file2', textBuffer, 'text.txt'); - // formData.append('folder', folderName); // Send folder name as form data - // formData.append('bucket', 'docs'); // Adjust bucket if needed + // formData.append('folder', folderName); // Send folder name + // formData.append('bucket', 'docs'); // Adjust bucket - // Send the POST request to upload the files const response = await axios.post( 'https://preschool-curriculum.in/api/one/v1/file/upload', formData, @@ -74,7 +69,6 @@ const aiTextToSpeech = async (req, res) => { } ); - // Return success response with URLs from the response res.json({ message: 'Speech generated and saved successfully', fileUrls: response.data.urls,