@fonoster/apiserver 0.7.27 → 0.7.29

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.
@@ -138,12 +138,8 @@ declare const services: Promise<[{
138
138
  getPublicKey: (_: unknown, callback: (error: import("@fonoster/common").GrpcErrorMessage, response?: {
139
139
  publicKey: string;
140
140
  }) => void) => Promise<void>;
141
- sendVerificationCode: (call: {
142
- request: unknown;
143
- }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
144
- verifyCode: (call: {
145
- request: unknown;
146
- }, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
141
+ sendVerificationCode: ReturnType<typeof import("@fonoster/identity/dist/verification").createSendVerificationCode>;
142
+ verifyCode: ReturnType<typeof import("@fonoster/identity/dist/verification").createVerifyCode>;
147
143
  };
148
144
  }, {
149
145
  definition: {
@@ -33,8 +33,8 @@ const logger_1 = require("@fonoster/logger");
33
33
  const handlers_1 = require("./handlers");
34
34
  const Stream_1 = require("./handlers/Stream");
35
35
  const types_1 = require("./types");
36
- const makeGetChannelVarWithoutThrow_1 = require("./utils/makeGetChannelVarWithoutThrow");
37
36
  const utils_1 = require("../utils");
37
+ const makeGetChannelVarWithoutThrow_1 = require("./utils/makeGetChannelVarWithoutThrow");
38
38
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
39
39
  class VoiceDispatcher {
40
40
  constructor(ari, nc, createVoiceClient) {
@@ -29,7 +29,6 @@ exports.gatherHandler = gatherHandler;
29
29
  * limitations under the License.
30
30
  */
31
31
  const common_1 = require("@fonoster/common");
32
- const messages_1 = require("@fonoster/common/src/messages");
33
32
  const zod_1 = require("zod");
34
33
  const getTimeoutPromise_1 = require("./getTimeoutPromise");
35
34
  const utils_1 = require("../utils");
@@ -41,16 +40,16 @@ const gatherRequestSchema = zod_1.z.object({
41
40
  maxDigits: zod_1.z
42
41
  .number()
43
42
  .int({
44
- message: messages_1.POSITIVE_INTEGER_MESSAGE
43
+ message: common_1.POSITIVE_INTEGER_MESSAGE
45
44
  })
46
45
  .positive({
47
- message: messages_1.POSITIVE_INTEGER_MESSAGE
46
+ message: common_1.POSITIVE_INTEGER_MESSAGE
48
47
  })
49
48
  .optional(),
50
49
  finishOnKey: zod_1.z
51
50
  .string()
52
51
  .regex(/^[0-9*#]$/)
53
- .max(1, { message: messages_1.MUST_BE_A_SINGLE_CHARACTER })
52
+ .max(1, { message: common_1.MUST_BE_A_SINGLE_CHARACTER })
54
53
  .optional()
55
54
  });
56
55
  function gatherHandler(voiceClient) {
@@ -0,0 +1,2 @@
1
+ declare function textChunksByFirstNaturalPause(text: string): string[];
2
+ export { textChunksByFirstNaturalPause };
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.textChunksByFirstNaturalPause = textChunksByFirstNaturalPause;
4
+ /* eslint-disable no-loops/no-loops */
5
+ /*
6
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
7
+ * http://github.com/fonoster/fonoster
8
+ *
9
+ * This file is part of Fonoster
10
+ *
11
+ * Licensed under the MIT License (the "License");
12
+ * you may not use this file except in compliance with
13
+ * the License. You may obtain a copy of the License at
14
+ *
15
+ * https://opensource.org/licenses/MIT
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ const CLAUSE_BOUNDARIES = /[.?!;]+/g;
24
+ function textChunksByFirstNaturalPause(text) {
25
+ var _a;
26
+ const boundary = (_a = text.match(CLAUSE_BOUNDARIES)) === null || _a === void 0 ? void 0 : _a[0];
27
+ if (!boundary) {
28
+ // No pause found, return the entire text as the first chunk
29
+ return [text.trim()];
30
+ }
31
+ const boundaryIndex = text.indexOf(boundary) + boundary.length;
32
+ const firstChunk = text.slice(0, boundaryIndex).trim();
33
+ const secondChunk = text.slice(boundaryIndex).trim();
34
+ return secondChunk ? [firstChunk, secondChunk] : [firstChunk];
35
+ }
@@ -70,7 +70,7 @@ const z = __importStar(require("zod"));
70
70
  const AbstractTextToSpeech_1 = require("./AbstractTextToSpeech");
71
71
  const isSsml_1 = require("./isSsml");
72
72
  const streamToBuffer_1 = require("./streamToBuffer");
73
- const textChunksByClause_1 = require("../handlers/utils/textChunksByClause");
73
+ const textChunksByFirstNaturalPause_1 = require("../handlers/utils/textChunksByFirstNaturalPause");
74
74
  const ENGINE_NAME = "tts.deepgram";
75
75
  exports.ENGINE_NAME = ENGINE_NAME;
76
76
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
@@ -90,7 +90,7 @@ class Deepgram extends AbstractTextToSpeech_1.AbstractTextToSpeech {
90
90
  logger.verbose(`synthesize [input: ${text}, isSsml=${(0, isSsml_1.isSsml)(text)} options: ${JSON.stringify(options)}]`);
91
91
  const { voice } = this.engineConfig.config;
92
92
  const ref = this.createMediaReference();
93
- const chunks = (0, textChunksByClause_1.textChunkTextByClause)(text);
93
+ const chunks = (0, textChunksByFirstNaturalPause_1.textChunksByFirstNaturalPause)(text);
94
94
  const stream = new stream_1.Readable({ read() { } });
95
95
  const results = new Array(chunks.length);
96
96
  let nextIndexToPush = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.7.27",
3
+ "version": "0.7.29",
4
4
  "description": "APIServer for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -21,12 +21,12 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@deepgram/sdk": "^3.5.1",
24
- "@fonoster/common": "^0.7.26",
25
- "@fonoster/identity": "^0.7.26",
26
- "@fonoster/logger": "^0.7.26",
27
- "@fonoster/sipnet": "^0.7.26",
28
- "@fonoster/streams": "^0.7.26",
29
- "@fonoster/types": "^0.7.26",
24
+ "@fonoster/common": "^0.7.29",
25
+ "@fonoster/identity": "^0.7.29",
26
+ "@fonoster/logger": "^0.7.29",
27
+ "@fonoster/sipnet": "^0.7.29",
28
+ "@fonoster/streams": "^0.7.29",
29
+ "@fonoster/types": "^0.7.29",
30
30
  "@google-cloud/speech": "^6.6.0",
31
31
  "@google-cloud/text-to-speech": "^5.3.0",
32
32
  "@grpc/grpc-js": "~1.10.6",
@@ -72,5 +72,5 @@
72
72
  "@types/uuid": "^9.0.8",
73
73
  "@types/validator": "^13.12.0"
74
74
  },
75
- "gitHead": "d483135107eca85932d8f75e4f6ff27cfaef51e3"
75
+ "gitHead": "9e147ecc7a4a96641dac70e1ce39af4bae40f396"
76
76
  }