diff --git a/commands/voice/animalese.js b/commands/voice/animalese.js index 0d287315..fee535f1 100644 --- a/commands/voice/animalese.js +++ b/commands/voice/animalese.js @@ -51,7 +51,11 @@ module.exports = class AnimaleseCommand extends Command { { key: 'text', prompt: 'What text should be said?', - type: 'string' + type: 'string', + validate: text => { + if (!this.processScript(text)) return 'This text has no audible characters.'; + return true; + } } ] }); @@ -76,7 +80,7 @@ module.exports = class AnimaleseCommand extends Command { } animalese(script, pitch) { - const processedScript = script.replace(/[^a-z]/gi, ' ').split(' ').map(this.shortenWord).join(''); + const processedScript = this.processScript(script); const data = []; const sampleFreq = 44100; const libraryLetterSecs = 0.15; @@ -108,4 +112,8 @@ module.exports = class AnimaleseCommand extends Command { } return str; } + + processScript(str) { + return str.replace(/[^a-z]/gi, ' ').split(' ').map(this.shortenWord).join(''); + } };