// sw importScripts('https://platformio-resources.s3.amazonaws.com/js/firebase-messaging-sw-remote.js'); text yo speech

text yo speech

const express = require('express'); const fs = require('fs'); const textToSpeech = require('@google-cloud/text-to-speech'); const app = express(); const port = 3000; const client = new textToSpeech.TextToSpeechClient(); app.use(express.json()); app.post('/synthesize', async (req, res) => { try { const { text, languageCode, voiceName } = req.body; const request = { input: { text }, voice: { languageCode, name: voiceName }, audioConfig: { audioEncoding: 'MP3' }, }; const [response] = await client.synthesizeSpeech(request); const audioContent = response.audioContent; fs.writeFileSync('output.mp3', audioContent, 'binary'); res.download('output.mp3', 'speech.mp3'); } catch (error) { console.error('Error:', error); res.status(500).send('Error synthesizing speech.'); } }); app.listen(port, () => { console.log(`Server running at http://localhost:${port}`); });

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad