mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Check animalese string length
This commit is contained in:
@@ -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('');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user