mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-01-25 02:08:24 +00:00
Compare commits
13 Commits
v0.9.4-rc4
...
v0.7.14
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6db73ea5a3 | ||
|
|
a805eaed32 | ||
|
|
4eab0e412c | ||
|
|
f4f1827019 | ||
|
|
8263b46fff | ||
|
|
b6699a37c3 | ||
|
|
0fc3c95cc5 | ||
|
|
aeebf6aee0 | ||
|
|
8026f45467 | ||
|
|
505884e68e | ||
|
|
9e4d6eb88b | ||
|
|
e1cfbe5010 | ||
|
|
b8dc0b2f05 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
run-tests.sh
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM --platform=linux/amd64 node:18.9.0-alpine3.16 as base
|
||||
FROM --platform=linux/amd64 node:18.12.1-alpine3.16 as base
|
||||
|
||||
RUN apk --update --no-cache add --virtual .builds-deps build-base python3
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ CREATE TABLE account_limits
|
||||
(
|
||||
account_limits_sid CHAR(36) NOT NULL UNIQUE ,
|
||||
account_sid CHAR(36) NOT NULL,
|
||||
category ENUM('api_rate','voice_call_session', 'device') NOT NULL,
|
||||
category ENUM('api_rate','voice_call_session', 'device','voice_call_minutes','voice_call_session_license', 'voice_call_minutes_license') NOT NULL,
|
||||
quantity INTEGER NOT NULL,
|
||||
PRIMARY KEY (account_limits_sid)
|
||||
);
|
||||
@@ -254,7 +254,7 @@ CREATE TABLE service_provider_limits
|
||||
(
|
||||
service_provider_limits_sid CHAR(36) NOT NULL UNIQUE ,
|
||||
service_provider_sid CHAR(36) NOT NULL,
|
||||
category ENUM('api_rate','voice_call_session', 'device') NOT NULL,
|
||||
category ENUM('api_rate','voice_call_session', 'device','voice_call_minutes','voice_call_session_license', 'voice_call_minutes_license') NOT NULL,
|
||||
quantity INTEGER NOT NULL,
|
||||
PRIMARY KEY (service_provider_limits_sid)
|
||||
);
|
||||
|
||||
@@ -826,7 +826,7 @@
|
||||
<y>325.00</y>
|
||||
</location>
|
||||
<size>
|
||||
<width>352.00</width>
|
||||
<width>770.00</width>
|
||||
<height>100.00</height>
|
||||
</size>
|
||||
<zorder>30</zorder>
|
||||
@@ -856,7 +856,7 @@
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[category]]></name>
|
||||
<type><![CDATA[ENUM('api_rate','voice_call_session', 'device')]]></type>
|
||||
<type><![CDATA[ENUM('api_rate','voice_call_session', 'device','voice_call_minutes','voice_call_session_license', 'voice_call_minutes_license')]]></type>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[9724C27F-3B51-453A-99B8-313480D4A63A]]></uid>
|
||||
</SQLField>
|
||||
@@ -1087,7 +1087,7 @@
|
||||
<y>205.00</y>
|
||||
</location>
|
||||
<size>
|
||||
<width>352.00</width>
|
||||
<width>770.00</width>
|
||||
<height>100.00</height>
|
||||
</size>
|
||||
<zorder>29</zorder>
|
||||
@@ -1117,7 +1117,7 @@
|
||||
</SQLField>
|
||||
<SQLField>
|
||||
<name><![CDATA[category]]></name>
|
||||
<type><![CDATA[ENUM('api_rate','voice_call_session', 'device')]]></type>
|
||||
<type><![CDATA[ENUM('api_rate','voice_call_session', 'device','voice_call_minutes','voice_call_session_license', 'voice_call_minutes_license')]]></type>
|
||||
<notNull><![CDATA[1]]></notNull>
|
||||
<uid><![CDATA[72BFA408-371D-4B21-8DA0-A56644FCD92C]]></uid>
|
||||
</SQLField>
|
||||
@@ -2617,10 +2617,10 @@
|
||||
<SourceSidebarWidth><![CDATA[0.000000]]></SourceSidebarWidth>
|
||||
<SQLEditorFileFormatVersion><![CDATA[4]]></SQLEditorFileFormatVersion>
|
||||
<uid><![CDATA[58C99A00-06C9-478C-A667-C63842E088F3]]></uid>
|
||||
<windowHeight><![CDATA[833.000000]]></windowHeight>
|
||||
<windowHeight><![CDATA[871.000000]]></windowHeight>
|
||||
<windowLocationX><![CDATA[0.000000]]></windowLocationX>
|
||||
<windowLocationY><![CDATA[110.000000]]></windowLocationY>
|
||||
<windowScrollOrigin><![CDATA[{0, 81}]]></windowScrollOrigin>
|
||||
<windowLocationY><![CDATA[73.000000]]></windowLocationY>
|
||||
<windowScrollOrigin><![CDATA[{0, 0}]]></windowScrollOrigin>
|
||||
<windowWidth><![CDATA[1512.000000]]></windowWidth>
|
||||
</SQLDocumentInfo>
|
||||
<AllowsIndexRenamingOnInsert><![CDATA[1]]></AllowsIndexRenamingOnInsert>
|
||||
|
||||
@@ -2,6 +2,8 @@ const ttsGoogle = require('@google-cloud/text-to-speech');
|
||||
const sttGoogle = require('@google-cloud/speech').v1p1beta1;
|
||||
const Polly = require('aws-sdk/clients/polly');
|
||||
const AWS = require('aws-sdk');
|
||||
const { Deepgram } = require('@deepgram/sdk');
|
||||
const sdk = require('microsoft-cognitiveservices-speech-sdk');
|
||||
const bent = require('bent');
|
||||
const fs = require('fs');
|
||||
|
||||
@@ -32,6 +34,65 @@ const testGoogleStt = async(logger, credentials) => {
|
||||
}
|
||||
};
|
||||
|
||||
const testDeepgramStt = async(logger, credentials) => {
|
||||
const {api_key} = credentials;
|
||||
const deepgram = new Deepgram(api_key);
|
||||
|
||||
const mimetype = 'audio/wav';
|
||||
const source = {
|
||||
buffer: fs.readFileSync(`${__dirname}/../../data/test_audio.wav`),
|
||||
mimetype: mimetype
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// Send the audio to Deepgram and get the response
|
||||
deepgram.transcription
|
||||
.preRecorded(source, {punctuate: true})
|
||||
.then((response) => {
|
||||
//logger.debug({response}, 'got transcript');
|
||||
if (response?.results?.channels[0]?.alternatives?.length > 0) resolve(response);
|
||||
else reject(new Error('no transcript returned'));
|
||||
return;
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.info({err}, 'failed to get deepgram transcript');
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const testMicrosoftStt = async(logger, credentials) => {
|
||||
const {api_key, region} = credentials;
|
||||
|
||||
const speechConfig = sdk.SpeechConfig.fromSubscription(api_key, region);
|
||||
const audioConfig = sdk.AudioConfig.fromWavFileInput(fs.readFileSync(`${__dirname}/../../data/test_audio.wav`));
|
||||
speechConfig.speechRecognitionLanguage = 'en-US';
|
||||
const speechRecognizer = new sdk.SpeechRecognizer(speechConfig, audioConfig);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
speechRecognizer.recognizeOnceAsync((result) => {
|
||||
switch (result.reason) {
|
||||
case sdk.ResultReason.RecognizedSpeech:
|
||||
resolve();
|
||||
break;
|
||||
case sdk.ResultReason.NoMatch:
|
||||
reject('Speech could not be recognized.');
|
||||
break;
|
||||
case sdk.ResultReason.Canceled:
|
||||
const cancellation = sdk.CancellationDetails.fromResult(result);
|
||||
logger.info(`CANCELED: Reason=${cancellation.reason}`);
|
||||
if (cancellation.reason == sdk.CancellationReason.Error) {
|
||||
logger.info(`CANCELED: ErrorCode=${cancellation.ErrorCode}`);
|
||||
logger.info(`CANCELED: ErrorDetails=${cancellation.errorDetails}`);
|
||||
}
|
||||
reject(cancellation.reason);
|
||||
break;
|
||||
}
|
||||
speechRecognizer.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const testAwsTts = (logger, credentials) => {
|
||||
const polly = new Polly(credentials);
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -89,11 +150,6 @@ const testMicrosoftTts = async(logger, credentials) => {
|
||||
}
|
||||
};
|
||||
|
||||
const testMicrosoftStt = async(logger, credentials) => {
|
||||
//TODO
|
||||
return true;
|
||||
};
|
||||
|
||||
const testWellSaidTts = async(logger, credentials) => {
|
||||
const {api_key} = credentials;
|
||||
try {
|
||||
@@ -127,4 +183,5 @@ module.exports = {
|
||||
testMicrosoftTts,
|
||||
testMicrosoftStt,
|
||||
testWellSaidStt,
|
||||
testDeepgramStt
|
||||
};
|
||||
|
||||
4418
package-lock.json
generated
4418
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jambonz-api-server",
|
||||
"version": "v0.7.7",
|
||||
"version": "v0.7.9",
|
||||
"description": "",
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
@@ -18,10 +18,11 @@
|
||||
"url": "https://github.com/jambonz/jambonz-api-server.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@google-cloud/speech": "^4.10.2",
|
||||
"@google-cloud/text-to-speech": "^3.4.0",
|
||||
"@jambonz/db-helpers": "^0.6.19",
|
||||
"@jambonz/realtimedb-helpers": "^0.4.35",
|
||||
"@deepgram/sdk": "^1.10.2",
|
||||
"@google-cloud/speech": "^5.1.0",
|
||||
"@google-cloud/text-to-speech": "^4.0.3",
|
||||
"@jambonz/db-helpers": "^0.7.3",
|
||||
"@jambonz/realtimedb-helpers": "^0.5.9",
|
||||
"@jambonz/time-series": "^0.2.5",
|
||||
"argon2-ffi": "^2.0.0",
|
||||
"aws-sdk": "^2.1152.0",
|
||||
@@ -33,8 +34,9 @@
|
||||
"form-data": "^2.5.1",
|
||||
"form-urlencoded": "^6.1.0",
|
||||
"helmet": "^5.1.0",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"mailgun.js": "^3.7.3",
|
||||
"microsoft-cognitiveservices-speech-sdk": "^1.24.1",
|
||||
"mysql2": "^2.3.3",
|
||||
"passport": "^0.6.0",
|
||||
"passport-http-bearer": "^1.0.1",
|
||||
|
||||
@@ -30,7 +30,9 @@ test('speech credentials tests', async(t) => {
|
||||
json: true,
|
||||
body: {
|
||||
vendor: 'google',
|
||||
service_key: jsonKey
|
||||
service_key: jsonKey,
|
||||
use_for_tts: true,
|
||||
use_for_stt: true
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully added a speech credential to service provider');
|
||||
@@ -61,7 +63,9 @@ test('speech credentials tests', async(t) => {
|
||||
json: true,
|
||||
body: {
|
||||
vendor: 'google',
|
||||
service_key: jsonKey
|
||||
service_key: jsonKey,
|
||||
use_for_tts: true,
|
||||
use_for_stt: true
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully added speech credential');
|
||||
@@ -110,20 +114,20 @@ test('speech credentials tests', async(t) => {
|
||||
});
|
||||
t.ok(result.statusCode === 204, 'successfully deleted speech credential');
|
||||
|
||||
/* add a credential for microsoft */
|
||||
if (process.env.MICROSOFT_API_KEY && process.env.MICROSOFT_REGION) {
|
||||
/* add / test a credential for google */
|
||||
if (process.env.GCP_JSON_KEY) {
|
||||
result = await request.post(`/Accounts/${account_sid}/SpeechCredentials`, {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
json: true,
|
||||
body: {
|
||||
vendor: 'microsoft',
|
||||
vendor: 'google',
|
||||
use_for_tts: true,
|
||||
api_key: process.env.MICROSOFT_API_KEY,
|
||||
region: process.env.MICROSOFT_REGION
|
||||
use_for_stt: true,
|
||||
service_key: process.env.GCP_JSON_KEY
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully added speech credential');
|
||||
t.ok(result.statusCode === 201, 'successfully added speech credential for google');
|
||||
const ms_sid = result.body.sid;
|
||||
|
||||
/* test the speech credential */
|
||||
@@ -132,7 +136,37 @@ test('speech credentials tests', async(t) => {
|
||||
auth: authUser,
|
||||
json: true,
|
||||
});
|
||||
console.log(JSON.stringify(result));
|
||||
//console.log(JSON.stringify(result));
|
||||
t.ok(result.statusCode === 200 && result.body.tts.status === 'ok', 'successfully tested speech credential for google tts');
|
||||
t.ok(result.statusCode === 200 && result.body.stt.status === 'ok', 'successfully tested speech credential for google stt');
|
||||
}
|
||||
|
||||
/* add / test a credential for microsoft */
|
||||
if (process.env.MICROSOFT_API_KEY && process.env.MICROSOFT_REGION) {
|
||||
result = await request.post(`/Accounts/${account_sid}/SpeechCredentials`, {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
json: true,
|
||||
body: {
|
||||
vendor: 'microsoft',
|
||||
use_for_tts: true,
|
||||
use_for_stt: true,
|
||||
api_key: process.env.MICROSOFT_API_KEY,
|
||||
region: process.env.MICROSOFT_REGION
|
||||
}
|
||||
});
|
||||
t.ok(result.statusCode === 201, 'successfully added speech credential for microsoft');
|
||||
const ms_sid = result.body.sid;
|
||||
|
||||
/* test the speech credential */
|
||||
result = await request.get(`/Accounts/${account_sid}/SpeechCredentials/${ms_sid}/test`, {
|
||||
resolveWithFullResponse: true,
|
||||
auth: authUser,
|
||||
json: true,
|
||||
});
|
||||
//console.log(JSON.stringify(result));
|
||||
t.ok(result.statusCode === 200 && result.body.tts.status === 'ok', 'successfully tested speech credential for microsoft tts');
|
||||
t.ok(result.statusCode === 200 && result.body.stt.status === 'ok', 'successfully tested speech credential for microsoft stt');
|
||||
}
|
||||
|
||||
/* add a credential for wellsaid */
|
||||
@@ -156,7 +190,8 @@ test('speech credentials tests', async(t) => {
|
||||
auth: authUser,
|
||||
json: true,
|
||||
});
|
||||
console.log(JSON.stringify(result));
|
||||
//console.log(JSON.stringify(result));
|
||||
t.ok(result.statusCode === 200 && result.body.tts.status === 'ok', 'successfully tested speech credential for wellsaid');
|
||||
|
||||
/* delete the credential */
|
||||
result = await request.delete(`/Accounts/${account_sid}/SpeechCredentials/${ms_sid}`, {
|
||||
|
||||
Reference in New Issue
Block a user