@fonoster/apiserver 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +3 -0
- package/dist/applications/buildService.d.ts +29 -0
- package/dist/applications/buildService.js +43 -0
- package/dist/applications/createApplication.d.ts +6 -0
- package/dist/applications/createApplication.js +56 -0
- package/dist/applications/createGetFnUtil.d.ts +33 -0
- package/dist/applications/createGetFnUtil.js +31 -0
- package/dist/applications/deleteApplication.d.ts +6 -0
- package/dist/applications/deleteApplication.js +25 -0
- package/dist/applications/getApplication.d.ts +6 -0
- package/dist/applications/getApplication.js +46 -0
- package/dist/applications/hostOrHostPortSchema.d.ts +3 -0
- package/dist/applications/hostOrHostPortSchema.js +34 -0
- package/dist/applications/index.d.ts +1 -0
- package/dist/applications/index.js +23 -0
- package/dist/applications/listApplications.d.ts +6 -0
- package/dist/applications/listApplications.js +68 -0
- package/dist/applications/types.d.ts +27 -0
- package/dist/applications/types.js +2 -0
- package/dist/applications/updateApplication.d.ts +8 -0
- package/dist/applications/updateApplication.js +56 -0
- package/dist/applications/utils/applicationWithEncodedStruct.d.ts +3 -0
- package/dist/applications/utils/applicationWithEncodedStruct.js +22 -0
- package/dist/applications/utils/convertToApplicationData.d.ts +4 -0
- package/dist/applications/utils/convertToApplicationData.js +37 -0
- package/dist/applications/utils/getApplicationValidationSchema.d.ts +64 -0
- package/dist/applications/utils/getApplicationValidationSchema.js +63 -0
- package/dist/applications/utils/prepareForValidation.d.ts +3 -0
- package/dist/applications/utils/prepareForValidation.js +35 -0
- package/dist/applications/utils/validOrThrow.d.ts +3 -0
- package/dist/applications/utils/validOrThrow.js +14 -0
- package/dist/calls/ListCallsRequestSchema.d.ts +28 -0
- package/dist/calls/ListCallsRequestSchema.js +58 -0
- package/dist/calls/buildService.d.ts +26 -0
- package/dist/calls/buildService.js +57 -0
- package/dist/calls/createCall.d.ts +6 -0
- package/dist/calls/createCall.js +63 -0
- package/dist/calls/createCallPublisher.d.ts +7 -0
- package/dist/calls/createCallPublisher.js +46 -0
- package/dist/calls/createFetchCalls.d.ts +3 -0
- package/dist/calls/createFetchCalls.js +86 -0
- package/dist/calls/createFetchSingleCall.d.ts +3 -0
- package/dist/calls/createFetchSingleCall.js +47 -0
- package/dist/calls/createTrackCallSubscriber.d.ts +5 -0
- package/dist/calls/createTrackCallSubscriber.js +52 -0
- package/dist/calls/getCall.d.ts +6 -0
- package/dist/calls/getCall.js +59 -0
- package/dist/calls/index.d.ts +1 -0
- package/dist/calls/index.js +23 -0
- package/dist/calls/influxdb.d.ts +2 -0
- package/dist/calls/influxdb.js +29 -0
- package/dist/calls/listCalls.d.ts +6 -0
- package/dist/calls/listCalls.js +51 -0
- package/dist/calls/runCallManager.d.ts +8 -0
- package/dist/calls/runCallManager.js +81 -0
- package/dist/calls/trackCall.d.ts +14 -0
- package/dist/calls/trackCall.js +63 -0
- package/dist/calls/types.d.ts +96 -0
- package/dist/calls/types.js +42 -0
- package/dist/core/allowList.d.ts +2 -0
- package/dist/core/allowList.js +31 -0
- package/dist/core/db.d.ts +13 -0
- package/dist/core/db.js +29 -0
- package/dist/core/filesServer.d.ts +5 -0
- package/dist/{ari_proxy.js → core/filesServer.js} +23 -20
- package/dist/core/identityConfig.d.ts +21 -0
- package/dist/core/identityConfig.js +43 -0
- package/dist/core/loadServices.d.ts +8 -0
- package/dist/core/loadServices.js +43 -0
- package/dist/core/notFoundError.d.ts +6 -0
- package/dist/core/notFoundError.js +27 -0
- package/dist/core/removeSwaggerNotice.d.ts +2 -0
- package/dist/core/removeSwaggerNotice.js +34 -0
- package/dist/core/routrConfig.d.ts +5 -0
- package/dist/core/routrConfig.js +27 -0
- package/dist/core/runServices.d.ts +2 -0
- package/dist/core/runServices.js +97 -0
- package/dist/core/seed.js +76 -0
- package/dist/core/services.d.ts +432 -0
- package/dist/core/services.js +53 -0
- package/dist/core/upsertDefaultPeer.d.ts +3 -0
- package/dist/core/upsertDefaultPeer.js +88 -0
- package/dist/envs.d.ts +46 -6
- package/dist/envs.js +94 -8
- package/dist/events/createInfluxDbPub.d.ts +13 -0
- package/dist/events/createInfluxDbPub.js +53 -0
- package/dist/events/nats.d.ts +10 -0
- package/dist/events/nats.js +84 -0
- package/dist/events/types.d.ts +8 -0
- package/dist/events/types.js +20 -0
- package/dist/index.js +53 -122
- package/dist/secrets/buildService.d.ts +31 -0
- package/dist/secrets/buildService.js +43 -0
- package/dist/secrets/createGetFnUtil.d.ts +16 -0
- package/dist/secrets/createGetFnUtil.js +45 -0
- package/dist/secrets/createSecret.d.ts +7 -0
- package/dist/secrets/createSecret.js +56 -0
- package/dist/secrets/deleteSecret.d.ts +8 -0
- package/dist/secrets/deleteSecret.js +43 -0
- package/dist/secrets/getSecret.d.ts +6 -0
- package/dist/secrets/getSecret.js +42 -0
- package/dist/secrets/index.d.ts +1 -0
- package/dist/secrets/index.js +23 -0
- package/dist/secrets/listSecrets.d.ts +7 -0
- package/dist/secrets/listSecrets.js +61 -0
- package/dist/secrets/types.d.ts +32 -0
- package/dist/secrets/types.js +2 -0
- package/dist/secrets/updateSecret.d.ts +8 -0
- package/dist/secrets/updateSecret.js +52 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/makeCheckNumberPreconditions.d.ts +6 -0
- package/dist/utils/makeCheckNumberPreconditions.js +48 -0
- package/dist/voice/ChannelVarNotFoundError.d.ts +5 -0
- package/dist/voice/ChannelVarNotFoundError.js +10 -0
- package/dist/voice/MethodNotImplementedError.d.ts +4 -0
- package/dist/voice/MethodNotImplementedError.js +27 -0
- package/dist/voice/VoiceClientImpl.d.ts +41 -0
- package/dist/voice/VoiceClientImpl.js +192 -0
- package/dist/voice/VoiceDispatcher.d.ts +17 -0
- package/dist/voice/VoiceDispatcher.js +99 -0
- package/dist/voice/VoiceServiceClientConst.d.ts +3 -0
- package/dist/voice/VoiceServiceClientConst.js +53 -0
- package/dist/voice/connectToAri.d.ts +2 -0
- package/dist/voice/connectToAri.js +79 -0
- package/dist/voice/createExternalMediaConfig.d.ts +9 -0
- package/dist/voice/createExternalMediaConfig.js +34 -0
- package/dist/voice/handlers/Answer.d.ts +5 -0
- package/dist/voice/handlers/Answer.js +24 -0
- package/dist/voice/handlers/Hangup.d.ts +5 -0
- package/dist/voice/handlers/Hangup.js +25 -0
- package/dist/voice/handlers/Mute.d.ts +4 -0
- package/dist/voice/handlers/Mute.js +27 -0
- package/dist/voice/handlers/Play.d.ts +4 -0
- package/dist/voice/handlers/Play.js +33 -0
- package/dist/voice/handlers/PlayDtmf.d.ts +4 -0
- package/dist/voice/handlers/PlayDtmf.js +27 -0
- package/dist/voice/handlers/PlaybackControl.d.ts +4 -0
- package/dist/voice/handlers/PlaybackControl.js +27 -0
- package/dist/voice/handlers/Record.d.ts +4 -0
- package/dist/voice/handlers/Record.js +58 -0
- package/dist/voice/handlers/Say.d.ts +4 -0
- package/dist/voice/handlers/Say.js +45 -0
- package/dist/voice/handlers/StasisEnd.d.ts +4 -0
- package/dist/voice/handlers/StasisEnd.js +27 -0
- package/dist/voice/handlers/Unmute.d.ts +4 -0
- package/dist/voice/handlers/Unmute.js +27 -0
- package/dist/voice/handlers/awaitForPlaybackFinished.d.ts +3 -0
- package/dist/voice/handlers/awaitForPlaybackFinished.js +25 -0
- package/dist/voice/handlers/awaitForRecordingFinished.d.ts +5 -0
- package/dist/voice/handlers/awaitForRecordingFinished.js +53 -0
- package/dist/voice/handlers/dial/Dial.d.ts +5 -0
- package/dist/voice/handlers/dial/Dial.js +71 -0
- package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +6 -0
- package/dist/voice/handlers/dial/handleChannelLeftBridge.js +29 -0
- package/dist/voice/handlers/dial/handleDialEvents.d.ts +5 -0
- package/dist/voice/handlers/dial/handleDialEvents.js +54 -0
- package/dist/voice/handlers/dial/handleStasisEnd.d.ts +3 -0
- package/dist/voice/handlers/dial/handleStasisEnd.js +19 -0
- package/dist/voice/handlers/dial/handleStasisStart.d.ts +9 -0
- package/dist/voice/handlers/dial/handleStasisStart.js +53 -0
- package/dist/voice/handlers/dial/recordChannel.d.ts +4 -0
- package/dist/voice/handlers/dial/recordChannel.js +45 -0
- package/dist/voice/handlers/gather/Gather.d.ts +3 -0
- package/dist/voice/handlers/gather/Gather.js +72 -0
- package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +8 -0
- package/dist/voice/handlers/gather/getTimeoutPromise.js +18 -0
- package/dist/voice/handlers/withErrorHandling.d.ts +4 -0
- package/dist/voice/handlers/withErrorHandling.js +35 -0
- package/dist/voice/integrations/ApplicationNotFoundError.d.ts +4 -0
- package/dist/voice/integrations/ApplicationNotFoundError.js +28 -0
- package/dist/voice/integrations/findIntegrationsCredentials.d.ts +3 -0
- package/dist/voice/integrations/findIntegrationsCredentials.js +6 -0
- package/dist/voice/integrations/getSttConfig.d.ts +7 -0
- package/dist/voice/integrations/getSttConfig.js +9 -0
- package/dist/voice/integrations/getTtsConfig.d.ts +7 -0
- package/dist/voice/integrations/getTtsConfig.js +10 -0
- package/dist/voice/integrations/index.d.ts +1 -0
- package/dist/voice/integrations/index.js +35 -0
- package/dist/voice/integrations/makeCreateContainer.d.ts +4 -0
- package/dist/voice/integrations/makeCreateContainer.js +88 -0
- package/dist/voice/integrations/types.d.ts +15 -0
- package/dist/voice/integrations/types.js +2 -0
- package/dist/voice/makeCreateVoiceClient.d.ts +9 -0
- package/dist/voice/makeCreateVoiceClient.js +77 -0
- package/dist/voice/makeGetChannelVar.d.ts +4 -0
- package/dist/voice/makeGetChannelVar.js +25 -0
- package/dist/voice/stt/AbstractSpeechToText.d.ts +14 -0
- package/dist/voice/stt/AbstractSpeechToText.js +19 -0
- package/dist/voice/stt/Google.d.ts +19 -0
- package/dist/voice/stt/Google.js +99 -0
- package/dist/voice/stt/SpeechToTextFactory.d.ts +9 -0
- package/dist/voice/stt/SpeechToTextFactory.js +41 -0
- package/dist/voice/stt/types.d.ts +25 -0
- package/dist/voice/stt/types.js +2 -0
- package/dist/voice/transcribeOnConnection.d.ts +4 -0
- package/dist/voice/transcribeOnConnection.js +26 -0
- package/dist/voice/tts/AbstractTextToSpeech.d.ts +18 -0
- package/dist/voice/tts/AbstractTextToSpeech.js +82 -0
- package/dist/voice/tts/Azure.d.ts +30 -0
- package/dist/voice/tts/Azure.js +128 -0
- package/dist/voice/tts/Google.d.ts +25 -0
- package/dist/voice/tts/Google.js +116 -0
- package/dist/voice/tts/TextToSpeechFactory.d.ts +9 -0
- package/dist/voice/tts/TextToSpeechFactory.js +43 -0
- package/dist/voice/tts/computeFilename.d.ts +7 -0
- package/dist/voice/tts/computeFilename.js +38 -0
- package/dist/voice/tts/flattenObject.d.ts +2 -0
- package/dist/voice/tts/flattenObject.js +38 -0
- package/dist/voice/tts/isSsml.d.ts +2 -0
- package/dist/voice/tts/isSsml.js +25 -0
- package/dist/voice/tts/types.d.ts +7 -0
- package/dist/voice/tts/types.js +2 -0
- package/dist/voice/types/ari.d.ts +21 -0
- package/dist/voice/types/ari.js +43 -0
- package/dist/voice/types/index.d.ts +2 -0
- package/dist/voice/types/index.js +36 -0
- package/dist/voice/types/voice.d.ts +33 -0
- package/dist/voice/types/voice.js +2 -0
- package/package.json +46 -36
- package/dist/upsert_peer.d.ts +0 -1
- package/dist/upsert_peer.js +0 -63
- /package/dist/{ari_proxy.d.ts → core/seed.d.ts} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.recordChannel = recordChannel;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@fonoster/common");
|
|
32
|
+
function recordChannel(ari, direction, sessionRef) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const channel = yield ari.channels.snoopChannel({
|
|
35
|
+
app: common_1.STASIS_APP_NAME,
|
|
36
|
+
channelId: sessionRef,
|
|
37
|
+
spy: direction
|
|
38
|
+
});
|
|
39
|
+
return ari.channels.record({
|
|
40
|
+
channelId: channel.id,
|
|
41
|
+
format: common_1.RecordFormat.WAV,
|
|
42
|
+
name: `${sessionRef}_${direction}`
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.gatherHandler = gatherHandler;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const common_1 = require("@fonoster/common");
|
|
32
|
+
const zod_1 = require("zod");
|
|
33
|
+
const getTimeoutPromise_1 = require("./getTimeoutPromise");
|
|
34
|
+
const withErrorHandling_1 = require("../withErrorHandling");
|
|
35
|
+
const isDtmf = (digit) => /^[0-9*#]+$/.test(digit);
|
|
36
|
+
const gatherRequestSchema = zod_1.z.object({
|
|
37
|
+
maxDigits: zod_1.z.number().optional().nullable(),
|
|
38
|
+
// TODO: Ensure it is a dtmf character
|
|
39
|
+
finishOnKey: zod_1.z.string().max(1).optional().nullable()
|
|
40
|
+
});
|
|
41
|
+
function gatherHandler(voiceClient) {
|
|
42
|
+
return (0, withErrorHandling_1.withErrorHandling)((request) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const { sessionRef, source, timeout, finishOnKey, maxDigits } = request;
|
|
44
|
+
// Error handled by withErrorHandling
|
|
45
|
+
gatherRequestSchema.parse(request);
|
|
46
|
+
const { timeoutPromise, effectiveTimeout } = (0, getTimeoutPromise_1.getTimeoutPromise)(timeout);
|
|
47
|
+
const effectiveSource = source || common_1.GatherSource.SPEECH_AND_DTMF;
|
|
48
|
+
const promises = [timeoutPromise];
|
|
49
|
+
if (effectiveSource.includes(common_1.GatherSource.SPEECH)) {
|
|
50
|
+
promises.push(voiceClient.transcribe().then((result) => result.speech));
|
|
51
|
+
}
|
|
52
|
+
if (effectiveSource.includes(common_1.GatherSource.DTMF)) {
|
|
53
|
+
promises.push(voiceClient
|
|
54
|
+
.waitForDtmf({
|
|
55
|
+
sessionRef,
|
|
56
|
+
finishOnKey,
|
|
57
|
+
maxDigits,
|
|
58
|
+
timeout: effectiveTimeout,
|
|
59
|
+
onDigitReceived: timeoutPromise.cancelGlobalTimer
|
|
60
|
+
})
|
|
61
|
+
.then(({ digits }) => digits));
|
|
62
|
+
}
|
|
63
|
+
const result = yield Promise.race(promises);
|
|
64
|
+
voiceClient.sendResponse({
|
|
65
|
+
gatherResponse: {
|
|
66
|
+
sessionRef,
|
|
67
|
+
speech: isDtmf(result) ? null : result,
|
|
68
|
+
digits: isDtmf(result) ? result : null
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTimeoutPromise = getTimeoutPromise;
|
|
4
|
+
function getTimeoutPromise(timeout) {
|
|
5
|
+
const effectiveTimeout = timeout || 5000;
|
|
6
|
+
let timeoutId = null;
|
|
7
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
8
|
+
timeoutId = setTimeout(() => {
|
|
9
|
+
resolve("");
|
|
10
|
+
}, effectiveTimeout);
|
|
11
|
+
});
|
|
12
|
+
timeoutPromise.cancelGlobalTimer = () => {
|
|
13
|
+
if (timeoutId) {
|
|
14
|
+
clearTimeout(timeoutId);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return { timeoutPromise, effectiveTimeout };
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.withErrorHandling = withErrorHandling;
|
|
13
|
+
const logger_1 = require("@fonoster/logger");
|
|
14
|
+
const zod_1 = require("zod");
|
|
15
|
+
const zod_validation_error_1 = require("zod-validation-error");
|
|
16
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
17
|
+
// TODO: Send error to the client and to the log system
|
|
18
|
+
function withErrorHandling(fn) {
|
|
19
|
+
return (request) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
return yield fn(request);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
if (err instanceof zod_1.z.ZodError) {
|
|
25
|
+
const validationError = (0, zod_validation_error_1.fromError)(err);
|
|
26
|
+
logger.error("Validation error:", {
|
|
27
|
+
message: validationError.toString()
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else if (err.message !== "Channel not found") {
|
|
31
|
+
throw err;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationNotFoundError = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
+
* http://github.com/fonoster/fonoster
|
|
7
|
+
*
|
|
8
|
+
* This file is part of Fonoster
|
|
9
|
+
*
|
|
10
|
+
* Licensed under the MIT License (the "License");
|
|
11
|
+
* you may not use this file except in compliance with
|
|
12
|
+
* the License. You may obtain a copy of the License at
|
|
13
|
+
*
|
|
14
|
+
* https://opensource.org/licenses/MIT
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
* See the License for the specific language governing permissions and
|
|
20
|
+
* limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
class ApplicationNotFoundError extends Error {
|
|
23
|
+
constructor(appRef) {
|
|
24
|
+
super(`Application not found: ${appRef}`);
|
|
25
|
+
this.name = this.constructor.name;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.ApplicationNotFoundError = ApplicationNotFoundError;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findIntegrationsCredentials = findIntegrationsCredentials;
|
|
4
|
+
function findIntegrationsCredentials(integrations, engine) {
|
|
5
|
+
return integrations.find((i) => i.productRef === engine);
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Application, VoiceLanguage } from "@fonoster/common";
|
|
2
|
+
import { IntegrationConfig } from "./types";
|
|
3
|
+
declare function getSttConfig(integrations: IntegrationConfig[], app: Application): {
|
|
4
|
+
credentials: IntegrationConfig;
|
|
5
|
+
languageCode: VoiceLanguage;
|
|
6
|
+
};
|
|
7
|
+
export { getSttConfig };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSttConfig = getSttConfig;
|
|
4
|
+
const findIntegrationsCredentials_1 = require("./findIntegrationsCredentials");
|
|
5
|
+
function getSttConfig(integrations, app) {
|
|
6
|
+
const config = app.speechToText.config;
|
|
7
|
+
const credentials = (0, findIntegrationsCredentials_1.findIntegrationsCredentials)(integrations, app.speechToText.productRef);
|
|
8
|
+
return Object.assign(Object.assign({}, config), { credentials });
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Application } from "@fonoster/common";
|
|
2
|
+
import { IntegrationConfig } from "./types";
|
|
3
|
+
declare function getTtsConfig(integrations: IntegrationConfig[], app: Application): {
|
|
4
|
+
credentials: IntegrationConfig;
|
|
5
|
+
pathToFiles: string;
|
|
6
|
+
};
|
|
7
|
+
export { getTtsConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTtsConfig = getTtsConfig;
|
|
4
|
+
const findIntegrationsCredentials_1 = require("./findIntegrationsCredentials");
|
|
5
|
+
const envs_1 = require("../../envs");
|
|
6
|
+
function getTtsConfig(integrations, app) {
|
|
7
|
+
const config = app.textToSpeech.config;
|
|
8
|
+
const credentials = (0, findIntegrationsCredentials_1.findIntegrationsCredentials)(integrations, app.textToSpeech.productRef);
|
|
9
|
+
return Object.assign(Object.assign({}, config), { credentials, pathToFiles: envs_1.TTS_PATH_TO_FILES });
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./makeCreateContainer";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./makeCreateContainer"), exports);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.makeCreateContainer = makeCreateContainer;
|
|
16
|
+
/*
|
|
17
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
18
|
+
* http://github.com/fonoster/fonoster
|
|
19
|
+
*
|
|
20
|
+
* This file is part of Fonoster
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the MIT License (the "License");
|
|
23
|
+
* you may not use this file except in compliance with
|
|
24
|
+
* the License. You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* https://opensource.org/licenses/MIT
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
const fs_1 = __importDefault(require("fs"));
|
|
35
|
+
const logger_1 = require("@fonoster/logger");
|
|
36
|
+
const zod_1 = require("zod");
|
|
37
|
+
const zod_validation_error_1 = require("zod-validation-error");
|
|
38
|
+
const ApplicationNotFoundError_1 = require("./ApplicationNotFoundError");
|
|
39
|
+
const getSttConfig_1 = require("./getSttConfig");
|
|
40
|
+
const getTtsConfig_1 = require("./getTtsConfig");
|
|
41
|
+
const SpeechToTextFactory_1 = require("../stt/SpeechToTextFactory");
|
|
42
|
+
const TextToSpeechFactory_1 = require("../tts/TextToSpeechFactory");
|
|
43
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
44
|
+
const integrationsConfigSchema = zod_1.z.array(zod_1.z.object({
|
|
45
|
+
name: zod_1.z.string(),
|
|
46
|
+
productRef: zod_1.z.string(),
|
|
47
|
+
type: zod_1.z.enum(["tts", "stt"]),
|
|
48
|
+
credentials: zod_1.z.record(zod_1.z.unknown())
|
|
49
|
+
}));
|
|
50
|
+
function makeCreateContainer(prisma, pathToIntegrations) {
|
|
51
|
+
logger.verbose("loading integrations config", { pathToIntegrations });
|
|
52
|
+
const integrationsFile = fs_1.default.readFileSync(pathToIntegrations, "utf8");
|
|
53
|
+
const integrations = JSON.parse(integrationsFile);
|
|
54
|
+
try {
|
|
55
|
+
integrationsConfigSchema.parse(integrations);
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
// fatal error
|
|
59
|
+
const message = (0, zod_validation_error_1.fromError)(e);
|
|
60
|
+
logger.error("integrations config is invalid", { message });
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
return (appRef) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
logger.verbose("creating integrations container", { appRef });
|
|
65
|
+
const app = yield prisma.application.findUnique({
|
|
66
|
+
where: { ref: appRef },
|
|
67
|
+
include: {
|
|
68
|
+
textToSpeech: true,
|
|
69
|
+
speechToText: true,
|
|
70
|
+
intelligence: true
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
if (!app) {
|
|
74
|
+
throw new ApplicationNotFoundError_1.ApplicationNotFoundError(appRef);
|
|
75
|
+
}
|
|
76
|
+
const ttsConfig = (0, getTtsConfig_1.getTtsConfig)(integrations, app);
|
|
77
|
+
const sttConfig = (0, getSttConfig_1.getSttConfig)(integrations, app);
|
|
78
|
+
const tts = TextToSpeechFactory_1.TextToSpeechFactory.getEngine(app.textToSpeech.productRef, ttsConfig);
|
|
79
|
+
const stt = SpeechToTextFactory_1.SpeechToTextFactory.getEngine(app.speechToText.productRef, sttConfig);
|
|
80
|
+
return {
|
|
81
|
+
ref: appRef,
|
|
82
|
+
accessKeyId: app.accessKeyId,
|
|
83
|
+
appEndpoint: app.appEndpoint,
|
|
84
|
+
tts,
|
|
85
|
+
stt
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AbstractSpeechToText } from "../stt/AbstractSpeechToText";
|
|
2
|
+
import { AbstractTextToSpeech } from "../tts/AbstractTextToSpeech";
|
|
3
|
+
type IntegrationConfig = {
|
|
4
|
+
productRef: string;
|
|
5
|
+
credentials: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
type IntegrationsContainer = {
|
|
8
|
+
ref: string;
|
|
9
|
+
accessKeyId: string;
|
|
10
|
+
appEndpoint: string;
|
|
11
|
+
tts: AbstractTextToSpeech<unknown>;
|
|
12
|
+
stt: AbstractSpeechToText<unknown>;
|
|
13
|
+
};
|
|
14
|
+
type CreateContainer = (appRef: string) => Promise<IntegrationsContainer>;
|
|
15
|
+
export { IntegrationConfig, IntegrationsContainer, CreateContainer };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Channel, Client, StasisStart } from "ari-client";
|
|
2
|
+
import { CreateContainer } from "./integrations/types";
|
|
3
|
+
import { VoiceClient } from "./types";
|
|
4
|
+
declare function makeCreateVoiceClient(createContainer: CreateContainer): (params: {
|
|
5
|
+
ari: Client;
|
|
6
|
+
event: StasisStart;
|
|
7
|
+
channel: Channel;
|
|
8
|
+
}) => Promise<VoiceClient>;
|
|
9
|
+
export { makeCreateVoiceClient };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.makeCreateVoiceClient = makeCreateVoiceClient;
|
|
13
|
+
/*
|
|
14
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
15
|
+
* http://github.com/fonoster/fonoster
|
|
16
|
+
*
|
|
17
|
+
* This file is part of Fonoster
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the MIT License (the "License");
|
|
20
|
+
* you may not use this file except in compliance with
|
|
21
|
+
* the License. You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* https://opensource.org/licenses/MIT
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
const identity_1 = require("@fonoster/identity");
|
|
32
|
+
const logger_1 = require("@fonoster/logger");
|
|
33
|
+
const makeGetChannelVar_1 = require("./makeGetChannelVar");
|
|
34
|
+
const types_1 = require("./types");
|
|
35
|
+
const VoiceClientImpl_1 = require("./VoiceClientImpl");
|
|
36
|
+
const identityConfig_1 = require("../core/identityConfig");
|
|
37
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
38
|
+
const createToken = (0, identity_1.createCallAccessToken)(identityConfig_1.identityConfig);
|
|
39
|
+
// Note: By the time the call arrives here the owner of the app MUST be authenticated
|
|
40
|
+
function makeCreateVoiceClient(createContainer) {
|
|
41
|
+
return (params) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
const { ari, event, channel } = params;
|
|
44
|
+
const { id: sessionRef, caller } = event.channel;
|
|
45
|
+
const { name: callerName, number: callerNumber } = caller;
|
|
46
|
+
const getChannelVar = (0, makeGetChannelVar_1.makeGetChannelVar)(channel);
|
|
47
|
+
// Variables set by Asterisk's dialplan
|
|
48
|
+
const appRef = (_a = (yield getChannelVar(types_1.ChannelVar.APP_REF))) === null || _a === void 0 ? void 0 : _a.value;
|
|
49
|
+
const ingressNumber = ((_b = (yield getChannelVar(types_1.ChannelVar.INGRESS_NUMBER))) === null || _b === void 0 ? void 0 : _b.value) || "";
|
|
50
|
+
const { accessKeyId, appEndpoint, tts, stt } = yield createContainer(appRef);
|
|
51
|
+
const sessionToken = yield createToken({ accessKeyId, appRef });
|
|
52
|
+
let metadataStr;
|
|
53
|
+
try {
|
|
54
|
+
metadataStr = (_c = (yield getChannelVar(types_1.ChannelVar.METADATA))) === null || _c === void 0 ? void 0 : _c.value;
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
// Do nothing
|
|
58
|
+
}
|
|
59
|
+
const config = {
|
|
60
|
+
appRef,
|
|
61
|
+
sessionRef,
|
|
62
|
+
accessKeyId,
|
|
63
|
+
appEndpoint,
|
|
64
|
+
callerName,
|
|
65
|
+
callerNumber,
|
|
66
|
+
ingressNumber,
|
|
67
|
+
sessionToken,
|
|
68
|
+
metadata: metadataStr ? JSON.parse(metadataStr) : {}
|
|
69
|
+
};
|
|
70
|
+
logger.verbose("creating voice client with config: ", {
|
|
71
|
+
appRef,
|
|
72
|
+
callerNumber,
|
|
73
|
+
ingressNumber
|
|
74
|
+
});
|
|
75
|
+
return new VoiceClientImpl_1.VoiceClientImpl({ ari, config, tts, stt });
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.makeGetChannelVar = makeGetChannelVar;
|
|
13
|
+
const ChannelVarNotFoundError_1 = require("./ChannelVarNotFoundError");
|
|
14
|
+
function makeGetChannelVar(channel) {
|
|
15
|
+
return (variable) => __awaiter(this, void 0, void 0, function* () {
|
|
16
|
+
try {
|
|
17
|
+
return yield channel.getChannelVar({
|
|
18
|
+
variable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
throw new ChannelVarNotFoundError_1.ChannelVarNotFoundError(variable);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Stream } from "stream";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { SpeechResult, StreamSpeechResult, SttConfig } from "./types";
|
|
4
|
+
declare abstract class AbstractSpeechToText<E, T extends SttConfig = SttConfig> {
|
|
5
|
+
abstract readonly engineName: E;
|
|
6
|
+
config: T;
|
|
7
|
+
constructor(config: T);
|
|
8
|
+
abstract streamTranscribe(stream: Stream): StreamSpeechResult;
|
|
9
|
+
abstract transcribe(stream: Stream): Promise<SpeechResult>;
|
|
10
|
+
getName(): E;
|
|
11
|
+
static getConfigValidationSchema(): z.Schema;
|
|
12
|
+
static getCredentialsValidationSchema(): z.Schema;
|
|
13
|
+
}
|
|
14
|
+
export { AbstractSpeechToText };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractSpeechToText = void 0;
|
|
4
|
+
const MethodNotImplementedError_1 = require("../MethodNotImplementedError");
|
|
5
|
+
class AbstractSpeechToText {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
getName() {
|
|
10
|
+
return this.engineName;
|
|
11
|
+
}
|
|
12
|
+
static getConfigValidationSchema() {
|
|
13
|
+
throw new MethodNotImplementedError_1.MethodNotImplementedError();
|
|
14
|
+
}
|
|
15
|
+
static getCredentialsValidationSchema() {
|
|
16
|
+
throw new MethodNotImplementedError_1.MethodNotImplementedError();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AbstractSpeechToText = AbstractSpeechToText;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Stream } from "stream";
|
|
2
|
+
import { SpeechClient } from "@google-cloud/speech";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { AbstractSpeechToText } from "./AbstractSpeechToText";
|
|
5
|
+
import { GoogleSttConfig, SpeechResult, StreamSpeechResult } from "./types";
|
|
6
|
+
declare const ENGINE_NAME = "stt.google";
|
|
7
|
+
declare class Google extends AbstractSpeechToText<typeof ENGINE_NAME> {
|
|
8
|
+
client: SpeechClient;
|
|
9
|
+
config: GoogleSttConfig;
|
|
10
|
+
readonly engineName = "stt.google";
|
|
11
|
+
protected readonly AUDIO_ENCODING = "LINEAR16";
|
|
12
|
+
protected readonly SAMPLE_RATE_HERTZ = 16000;
|
|
13
|
+
constructor(config: GoogleSttConfig);
|
|
14
|
+
streamTranscribe(_: Stream): StreamSpeechResult;
|
|
15
|
+
transcribe(stream: Stream): Promise<SpeechResult>;
|
|
16
|
+
static getConfigValidationSchema(): z.Schema;
|
|
17
|
+
static getCredentialsValidationSchema(): z.Schema;
|
|
18
|
+
}
|
|
19
|
+
export { Google, ENGINE_NAME };
|