@fonoster/voice 0.15.20 → 0.16.0

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.
@@ -16,7 +16,7 @@
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- import { DialOptions, GatherOptions, GatherResponse, MuteOptions, PlaybackControlAction, PlayOptions, PlayResponse, RecordOptions, RecordResponse, SayOptions, SayResponse, StreamEvent, StreamGatherOptions, StreamOptions, VerbResponse, VoiceRequest, VoiceSessionStreamServer } from "@fonoster/common";
19
+ import { DialOptions, GatherOptions, GatherResponse, MuteOptions, PlaybackControlAction, PlayOptions, PlayResponse, RecordOptions, RecordResponse, SayOptions, StreamEvent, StreamGatherOptions, StreamOptions, VerbResponse, VoiceRequest, VoiceSessionStreamServer } from "@fonoster/common";
20
20
  import { DialStatusStream, Stream, StreamGatherStream } from "./verbs";
21
21
  /**
22
22
  * @classdesc Use the VoiceResponse object, to construct advance Interactive
@@ -146,7 +146,24 @@ declare class VoiceResponse {
146
146
  * await response.playbackControl(playbackRef, PlaybackControlAction.STOP);
147
147
  * }
148
148
  */
149
- say(text: string, options?: SayOptions): Promise<SayResponse>;
149
+ say(text: string, options?: SayOptions): Promise<VerbResponse>;
150
+ /**
151
+ * Stop the current TTS operation.
152
+ * @example
153
+ *
154
+ * async function handler (request, response) {
155
+ * await response.answer();
156
+ *
157
+ * // Some async operation
158
+ * setTimeout(() => {
159
+ * // Will stop the current TTS operation
160
+ * response.stopSay();
161
+ * }, 10000);
162
+ *
163
+ * await response.say("Long text to say...");
164
+ * }
165
+ */
166
+ stopSay(): Promise<VerbResponse>;
150
167
  /**
151
168
  * Record the audio of the call.
152
169
  *
@@ -198,13 +198,36 @@ class VoiceResponse {
198
198
  */
199
199
  say(text, options) {
200
200
  return __awaiter(this, void 0, void 0, function* () {
201
- const response = yield new verbs_1.Say(this.request, this.voice).run({
202
- playbackRef: options === null || options === void 0 ? void 0 : options.playbackRef,
201
+ yield new verbs_1.Say(this.request, this.voice).run({
203
202
  options: options ? pb_util_1.struct.encode(options) : undefined,
204
203
  sessionRef: this.request.sessionRef,
205
204
  text
206
205
  });
207
- return { playbackRef: response.sayResponse.playbackRef };
206
+ return { sessionRef: this.request.sessionRef };
207
+ });
208
+ }
209
+ /**
210
+ * Stop the current TTS operation.
211
+ * @example
212
+ *
213
+ * async function handler (request, response) {
214
+ * await response.answer();
215
+ *
216
+ * // Some async operation
217
+ * setTimeout(() => {
218
+ * // Will stop the current TTS operation
219
+ * response.stopSay();
220
+ * }, 10000);
221
+ *
222
+ * await response.say("Long text to say...");
223
+ * }
224
+ */
225
+ stopSay() {
226
+ return __awaiter(this, void 0, void 0, function* () {
227
+ yield new verbs_1.StopSay(this.request, this.voice).run({
228
+ sessionRef: this.request.sessionRef
229
+ });
230
+ return { sessionRef: this.request.sessionRef };
208
231
  });
209
232
  }
210
233
  /**
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
+ * http://github.com/fonoster/fonoster
4
+ *
5
+ * This file is part of Fonoster
6
+ *
7
+ * Licensed under the MIT License (the "License");
8
+ * you may not use this file except in compliance with
9
+ * the License. You may obtain a copy of the License at
10
+ *
11
+ * https://opensource.org/licenses/MIT
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ import { StopSayRequest } from "@fonoster/common";
20
+ import { z } from "zod";
21
+ import { Verb } from "./Verb";
22
+ declare class StopSay extends Verb<StopSayRequest> {
23
+ getValidationSchema(): z.Schema;
24
+ }
25
+ export { StopSay };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StopSay = void 0;
4
+ const zod_1 = require("zod");
5
+ const Verb_1 = require("./Verb");
6
+ class StopSay extends Verb_1.Verb {
7
+ getValidationSchema() {
8
+ return zod_1.z.object({});
9
+ }
10
+ }
11
+ exports.StopSay = StopSay;
@@ -31,3 +31,4 @@ export * from "./StreamGather";
31
31
  export * from "./Unmute";
32
32
  export * from "./Verb";
33
33
  export * from "./validateRequest";
34
+ export * from "./StopSay";
@@ -47,3 +47,4 @@ __exportStar(require("./StreamGather"), exports);
47
47
  __exportStar(require("./Unmute"), exports);
48
48
  __exportStar(require("./Verb"), exports);
49
49
  __exportStar(require("./validateRequest"), exports);
50
+ __exportStar(require("./StopSay"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/voice",
3
- "version": "0.15.20",
3
+ "version": "0.16.0",
4
4
  "description": "Voice Server for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -21,9 +21,9 @@
21
21
  "fonoster": "./dist/index.js"
22
22
  },
23
23
  "dependencies": {
24
- "@fonoster/common": "^0.15.20",
25
- "@fonoster/identity": "^0.15.20",
26
- "@fonoster/logger": "^0.15.20",
24
+ "@fonoster/common": "^0.16.0",
25
+ "@fonoster/identity": "^0.16.0",
26
+ "@fonoster/logger": "^0.16.0",
27
27
  "@grpc/grpc-js": "~1.10.6",
28
28
  "deepmerge": "^4.3.1",
29
29
  "grpc-health-check": "^2.0.2",
@@ -44,5 +44,5 @@
44
44
  "bugs": {
45
45
  "url": "https://github.com/fonoster/fonoster/issues"
46
46
  },
47
- "gitHead": "65a0a5c60b7401e949e90af22db5a74ca37a601e"
47
+ "gitHead": "ad4212a7938ad2e219b9d1ae27a430ec60d9f841"
48
48
  }