New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fonos/voice

Package Overview
Dependencies
Maintainers
1
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fonos/voice - npm Package Compare versions

Comparing version 0.0.50 to 0.0.51

8

dist/gather.js

@@ -10,15 +10,15 @@ "use strict";

if (value && value.length > 1)
throw `${name} must a single char. Default value is #. Acceptable values are digits from 0-9,#,*`;
throw new Error(`@fonos/voice.Gather [${name} must a single char. Default value is #. Acceptable values are digits from 0-9,#,*]`);
};
const validateTimeout = (timeout) => {
if (timeout && (isNaN(timeout) || timeout < 0))
throw `${timeout} is not an acceptable timeout value. For no timeout use zero. Timeout must be equal or greater than zero`;
throw new Error(`@fonos/voice.Gather [${timeout} is not an acceptable timeout value. For no timeout use zero. Timeout must be equal or greater than zero]`);
};
const validateMaxDigits = (maxDigits) => {
if ((maxDigits && isNaN(maxDigits)) || maxDigits <= 0)
throw `${maxDigits} is not an acceptable maxDigits value. The maxDigits value must be greater than zero. Omit value for no limit on the number of digits`;
throw new Error(`@fonos/voice.Gather [${maxDigits} is not an acceptable maxDigits value. The maxDigits value must be greater than zero. Omit value for no limit on the number of digits]`);
};
const validateHasMaxDigitsOrTimeout = (options) => {
if (!options.maxDigits && !options.timeout)
throw `you must provide either maxDigits or timeout`;
throw new Error(`@fonos/voice.Gather [you must provide either maxDigits or timeout]`);
};

@@ -25,0 +25,0 @@ const foundFinishKey = (c, finishOnKey) => c === finishOnKey;

@@ -7,4 +7,4 @@ import Verb from './verb';

constructor(channel: any, config: any);
run(file: string, options?: PlayOptions): any;
run(file: string, options?: PlayOptions): string;
}
export { Play as default, PlayOptions };

@@ -8,2 +8,3 @@ "use strict";

const verb_1 = __importDefault(require("./verb"));
const logger_1 = __importDefault(require("@fonos/logger"));
const validate = (file, options) => {

@@ -24,8 +25,20 @@ const { finishOnKey = '#' } = options;

validate(file, options);
logger_1.default.log('debug', `@fonos/voice.Play [streaming file '${file}' from Media Server to endpoint]`);
const result = this.channel.streamFile(file, finishOnKey);
if (result.code === 200)
return result.attributes.result;
throw result.rawReply;
logger_1.default.log('debug', `@fonos/voice.Play [rawReply from Media Server '${result.rawReply}'`);
if (result.code === 200) {
const res = parseInt(result.attributes.result);
if (res > 1) {
const charFromCode = String.fromCharCode(res);
logger_1.default.log('debug', `@fonos/voice.Play [key pressed '${charFromCode}'`);
return charFromCode;
}
if (res === 0) {
logger_1.default.log('debug', `@fonos/voice.Play [key pressed ''`);
return '';
}
}
throw new Error(result.rawReply);
}
}
exports.default = Play;

@@ -22,15 +22,25 @@ "use strict";

synth(text, filename, options) {
const pathToFile = this.config.tts.synthesizeSync(text, options);
const pathToTranscodedFile = path_1.default.join(path_1.default.dirname(pathToFile), filename);
tts_1.transcodeSync(pathToFile, pathToTranscodedFile);
const metadata = { 'Content-Type': 'audio/x-wav' };
this.config.storage.uploadObjectSync({
filename: pathToTranscodedFile,
bucket: this.config.bucket,
metadata
});
return this.config.storage.getObjectURLSync({
name: filename,
bucket: this.config.bucket
});
try {
const pathToFile = this.config.tts.synthesizeSync(text, options);
const pathToTranscodedFile = path_1.default.join(path_1.default.dirname(pathToFile), filename);
tts_1.transcodeSync(pathToFile, pathToTranscodedFile);
const metadata = { 'Content-Type': 'audio/x-wav' };
this.config.storage.uploadObjectSync({
filename: pathToTranscodedFile,
bucket: this.config.bucket,
metadata
});
if (process.env.NODE_ENV === 'dev') {
logger_1.default.log('debug', '@fonos/voice.Say [generating file url using enviroment variables from client side]');
return `http://${process.env.FS_HOST}:${process.env.FS_PORT}/${this.config.bucket}/${filename}`;
}
return this.config.storage.getObjectURLSync({
name: filename,
bucket: this.config.bucket
});
}
catch (e) {
logger_1.default.log('error', '@fonos/voice.Say [error synthesizing audio]');
throw new Error(`@fonos/voice.Say [${e}]`);
}
}

@@ -47,6 +57,4 @@ run(text, options) {

});
// We add this because in development the files server
// could be at a remote network
if (process.env.NODE_ENV === 'dev') {
logger_1.default.log('debug', `@fonos/voice.Say [generating file url using enviroment variables from client side]`);
logger_1.default.log('debug', '@fonos/voice.Say [generating file url using enviroment variables from client side]');
url = `http://${process.env.FS_HOST}:${process.env.FS_PORT}/${this.config.bucket}/${filename}`;

@@ -60,5 +68,10 @@ }

url = this.synth(text, filename, options);
return new play_1.default(this.channel, this.config).run(url, options);
try {
return new play_1.default(this.channel, this.config).run(url, options);
}
catch (e) {
throw new Error(`@fonos/voice.Say [${e}] (failed to play)`);
}
}
}
exports.default = Say;
{
"name": "@fonos/voice",
"version": "0.0.50",
"version": "0.0.51",
"description": "Voice verbs",

@@ -37,8 +37,8 @@ "author": "Pedro Sanders <sanderspedro@gmail.com>",

"dependencies": {
"@fonos/events": "^0.0.50",
"@fonos/logger": "^0.0.50",
"@fonos/tts": "^0.0.50",
"@fonos/events": "^0.0.51",
"@fonos/logger": "^0.0.51",
"@fonos/tts": "^0.0.51",
"objectid": "^3.2.1"
},
"gitHead": "c93948a93f53b9f9683f5afa10f5e195d160b8ce"
"gitHead": "cf88b2710f2643fb3494f79cad13cffa1e89ab33"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc