guilevi 2021-09-15 02:09:55 +02:00
commit cd0ae8aadf
5 changed files with 11 additions and 1 deletions

View File

@ -1,4 +1,6 @@
const printf=require('printf'); const printf=require('printf');
const fs = require('fs');
const path = require('path');
module.exports = async (bot, api) => { module.exports = async (bot, api) => {
bot.on('message', async (message) => { bot.on('message', async (message) => {
@ -37,4 +39,11 @@ module.exports = async (bot, api) => {
api.respond(message, printf(api.strings.INVALID_ENGINE, args[1])); api.respond(message, printf(api.strings.INVALID_ENGINE, args[1]));
} }
}); });
api.registerCommand('random', async (args, message) => {
const files = fs.readdirSync(process.env["VOICE_TMP_PATH"]);
const rnd = files[Math.floor(Math.random()*files.length)];
console.log(rnd);
api.queue.add(__dirname + "/../../sysmsg.wav");
api.queue.add(process.env["VOICE_TMP_PATH"] + "/" + rnd);
});
} }

View File

@ -8,6 +8,7 @@ module.exports = function (bot, api) {
await api.joinChannel(channel); await api.joinChannel(channel);
let conn=api.getConnectionForVoiceChannel(channel); let conn=api.getConnectionForVoiceChannel(channel);
api.queue=new AudioQueue(conn); api.queue=new AudioQueue(conn);
api.queue.add(__dirname + "/../../sysstart.wav");
api.speak(channel, api.strings.WELCOME); api.speak(channel, api.strings.WELCOME);
}) })
} }

Binary file not shown.

BIN
sysstart.wav 100644

Binary file not shown.

View File

@ -26,7 +26,7 @@ module.exports = class GoogleCloudTTS extends BaseEngine {
const request = { const request = {
input: { text: text }, input: { text: text },
voice: { name: this.voices[voice].name, languageCode: this.voices[voice].lang }, voice: { name: this.voices[voice].name, languageCode: this.voices[voice].lang },
audioConfig: { audioEncoding: 'OGG_OPUS', effectsProfileId: ['medium-bluetooth-speaker-class-device'] }, audioConfig: { audioEncoding: 'LINEAR16' },
}; };
let [response] = await this.client.synthesizeSpeech(request); let [response] = await this.client.synthesizeSpeech(request);
const writeFile = util.promisify(fs.writeFile); const writeFile = util.promisify(fs.writeFile);