@fonoster/apiserver 0.7.26 → 0.7.27
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.
|
@@ -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
|
|
73
|
+
const textChunksByClause_1 = require("../handlers/utils/textChunksByClause");
|
|
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,
|
|
93
|
+
const chunks = (0, textChunksByClause_1.textChunkTextByClause)(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.
|
|
3
|
+
"version": "0.7.27",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"@types/uuid": "^9.0.8",
|
|
73
73
|
"@types/validator": "^13.12.0"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "d483135107eca85932d8f75e4f6ff27cfaef51e3"
|
|
76
76
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
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
|
-
}
|