Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Betabot #81

Merged
merged 16 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fry: You know the worst thing about being a slave? They make you work…
…, but they don't pay you or let you go.
  • Loading branch information
wootosmash committed Jan 12, 2020
commit 46ef1ec5859341413731a5bf4c36d6d4b2083680
3 changes: 1 addition & 2 deletions src/services/tts/AzureTextToSpeechAPI.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/*jshint esversion: 9 */
// class for all the details of a command
const Common = require('@helpers/common'),
TextToSpeechService = require('@services/TextToSpeechService'),
auth = require("@auth"),
rp = require('request-promise'),
prism = require('prism-media'),
fs = require('fs'),
lame = require('lame'),
samplerate = require('node-libsamplerate'),
xmlbuilder = require('xmlbuilder');
Expand Down Expand Up @@ -221,6 +219,7 @@ class AzureTextToSpeechAPI extends TextToSpeechService {
return '';
}

// gets a temporary token that lasts a short while to access the service
async getAccessToken(subscriptionKey) {
let options = {
method: 'POST',
Expand Down
15 changes: 8 additions & 7 deletions src/services/tts/PollyTTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ class PollyTTS {
})
}

async textToSpeech(options, callback) {
async textToSpeech(options) {

return new Promise((resolve, reject) => {

if (!options) {
return reject("Options are missing");
reject("Options are missing");
return;
}
let qs = {
Text: options.text,
Expand All @@ -73,13 +74,13 @@ class PollyTTS {
aws4.sign(opts, this.credentials);
https.get(opts, res => {
if (res.statusCode !== 200) {
throw new Error(`Request Failed. Status Code: ${res.statusCode}`)
reject(`Request Failed. Status Code: ${res.statusCode}`);
}
else {
resolve(res);
}
resolve(res);
})
.on("error", e => {
reject(e);
});
.on("error", reject);
})
}
}
Expand Down