--raw option

This commit is contained in:
loicbersier 2020-02-19 23:33:23 +01:00
parent b5c29cba29
commit af1ae7d4f1

View file

@ -14,10 +14,15 @@ class midifyCommand extends Command {
{ {
id: 'link', id: 'link',
type: 'string', type: 'string',
},
{
id: 'raw',
type: 'flag',
flag: '--raw'
} }
], ],
description: { description: {
content: 'Transform the audio into midi', content: 'Transform the audio into midi --raw to get the .mid file',
usage: '[link to video/music/whatever you want to be midi]', usage: '[link to video/music/whatever you want to be midi]',
examples: ['https://www.youtube.com/watch?v=kXYiU_JCYtU'] examples: ['https://www.youtube.com/watch?v=kXYiU_JCYtU']
} }
@ -66,6 +71,17 @@ class midifyCommand extends Command {
// wav to midi // wav to midi
exec(`waon -i ${input2} -o ${output}`) exec(`waon -i ${input2} -o ${output}`)
.then(() => { .then(() => {
if (args.raw) {
loadingmsg.delete();
return message.channel.send({files: [output]})
.catch(err => {
console.error(err);
loadingmsg.delete();
return message.channel.send('On no! an error just occured! perhaps the file is too big?');
});
}
// midi to mp3 so we can listen from discord // midi to mp3 so we can listen from discord
exec(`timidity ${output} -Ow -o - | ffmpeg -i - -acodec libmp3lame -ab 64k ${output2}`) exec(`timidity ${output} -Ow -o - | ffmpeg -i - -acodec libmp3lame -ab 64k ${output2}`)
.then(() => { .then(() => {