Abdalaziz A: ب

الأحد، 7 يناير 2024

ب

السلام عليكم const fs = require('fs'); const textToSpeech = require('@google-cloud/text-to-speech'); // Configure the Google Text-to-Speech API client const client = new textToSpeech.TextToSpeechClient({ // Add your Google Cloud credentials here keyFilename: 'path/to/your/credentials.json', }); // Define the text to be converted to speech const text = 'Your text goes here'; // Configure the speech synthesis request const request = { input: { text: text }, voice: { languageCode: 'en-US', ssmlGender: 'NEUTRAL' }, audioConfig: { audioEncoding: 'MP3' }, }; // Perform the text-to-speech conversion client.synthesizeSpeech(request, (err, response) => { if (err) { console.error('Error:', err); return; } // Save the audio response to an MP3 file fs.writeFile('output.mp3', response.audioContent, 'binary', err => { if (err) { console.error('Error saving audio:', err); return; } console.log('Audio saved successfully!'); }); });

0 تعليقات:

إرسال تعليق

الاشتراك في تعليقات الرسالة [Atom]

<< الصفحة الرئيسية