@fonoster/apiserver 0.27.0 → 0.31.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.
- package/dist/applications/buildService.d.ts +5 -1
- package/dist/applications/buildService.js +10 -7
- package/dist/applications/createCreateApplication.d.ts +6 -2
- package/dist/applications/createCreateApplication.js +24 -16
- package/dist/applications/createCreateTestToken.d.ts +3 -1
- package/dist/applications/createCreateTestToken.js +18 -13
- package/dist/applications/createGetApplication.js +2 -2
- package/dist/applications/createGetFnUtil.d.ts +22 -18
- package/dist/applications/createGetFnUtil.js +3 -5
- package/dist/applications/createListApplications.js +3 -4
- package/dist/applications/createRotateSigningSecret.d.ts +9 -0
- package/dist/{calls/createFetchSingleCall.js → applications/createRotateSigningSecret.js} +23 -20
- package/dist/applications/createUpdateApplication.d.ts +6 -2
- package/dist/applications/createUpdateApplication.js +35 -36
- package/dist/applications/evalKeys.d.ts +9 -0
- package/dist/{voice/handlers/dial/recordChannel.js → applications/evalKeys.js} +17 -12
- package/dist/applications/session/appModel.d.ts +225 -0
- package/dist/applications/session/appModel.js +331 -0
- package/dist/applications/types.d.ts +1 -27
- package/dist/billing/buildService.d.ts +24 -0
- package/dist/billing/buildService.js +116 -0
- package/dist/bin/entrypoint.d.ts +1 -0
- package/dist/bin/entrypoint.js +180 -0
- package/dist/bin/healthcheck.d.ts +2 -0
- package/dist/{voice/utils/VoiceServiceClientConstructor.js → bin/healthcheck.js} +24 -9
- package/dist/bin/regionHubSetup.d.ts +2 -0
- package/dist/bin/regionHubSetup.js +67 -0
- package/dist/bin/usage.d.ts +2 -0
- package/dist/bin/usage.js +119 -0
- package/dist/calls/buildService.d.ts +1 -20
- package/dist/calls/buildService.js +59 -6
- package/dist/calls/createCall.d.ts +17 -2
- package/dist/calls/createCall.js +64 -11
- package/dist/calls/createCallPublisher.d.ts +40 -2
- package/dist/calls/createCallPublisher.js +43 -9
- package/dist/calls/createIsWorkspaceNumber.d.ts +41 -0
- package/dist/calls/createIsWorkspaceNumber.js +39 -0
- package/dist/calls/createTrackCall.d.ts +55 -2
- package/dist/calls/createTrackCall.js +230 -16
- package/dist/calls/getCall.d.ts +4 -2
- package/dist/calls/getCall.js +2 -3
- package/dist/calls/listCalls.d.ts +4 -2
- package/dist/calls/listCalls.js +2 -3
- package/dist/calls/types.d.ts +11 -2
- package/dist/calls/types.js +10 -0
- package/dist/{core/buildWelcomeDemoService.d.ts → capabilities/buildService.d.ts} +8 -8
- package/dist/capabilities/buildService.js +17 -0
- package/dist/capabilities/createGetCapabilities.d.ts +78 -0
- package/dist/capabilities/createGetCapabilities.js +98 -0
- package/dist/{voice/handlers/utils → capabilities}/index.d.ts +2 -3
- package/dist/{voice/handlers/utils → capabilities}/index.js +4 -3
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.js +102 -0
- package/dist/config/schema.d.ts +1919 -0
- package/dist/config/schema.js +357 -0
- package/dist/core/allowList.js +2 -1
- package/dist/core/applyCatalog.d.ts +10 -0
- package/dist/{voice/client/GrpcClientHandler.js → core/applyCatalog.js} +45 -51
- package/dist/core/db.d.ts +3 -1
- package/dist/core/db.js +2 -1
- package/dist/core/durableConsumer.d.ts +41 -0
- package/dist/core/durableConsumer.js +104 -0
- package/dist/core/httpBridge.d.ts +24 -6
- package/dist/core/httpBridge.js +3 -25
- package/dist/core/identityConfig.d.ts +2 -35
- package/dist/core/identityConfig.js +3 -36
- package/dist/core/regionHooks.d.ts +15 -0
- package/dist/{calls/influxdb.js → core/regionHooks.js} +4 -8
- package/dist/core/runServices.js +98 -15
- package/dist/core/services.d.ts +96 -6
- package/dist/core/services.js +49 -10
- package/dist/{voice/errors/index.d.ts → core/telemetry.d.ts} +2 -2
- package/dist/core/telemetry.js +42 -0
- package/dist/{applications/utils/convertToApplicationData.d.ts → core/telemetryInterceptor.d.ts} +10 -4
- package/dist/core/telemetryInterceptor.js +57 -0
- package/dist/core/testTokenConfig.js +4 -1
- package/dist/core/upsertRoomrPeer.d.ts +6 -0
- package/dist/core/{upsertDefaultPeer.js → upsertRoomrPeer.js} +31 -30
- package/dist/envs.d.ts +136 -23
- package/dist/envs.js +108 -143
- package/dist/index.js +39 -21
- package/dist/outbound/createNodeDirectory.d.ts +86 -0
- package/dist/outbound/createNodeDirectory.js +140 -0
- package/dist/{voice/integrations → outbound}/index.d.ts +4 -1
- package/dist/{voice/errors → outbound}/index.js +4 -2
- package/dist/outbound/placeOutboundCall.d.ts +96 -0
- package/dist/outbound/placeOutboundCall.js +172 -0
- package/dist/outbound/placementSweep.d.ts +56 -0
- package/dist/outbound/placementSweep.js +127 -0
- package/dist/outbound/runOutboundCalls.d.ts +52 -0
- package/dist/outbound/runOutboundCalls.js +171 -0
- package/dist/providers/createProvidersHandlers.d.ts +39 -0
- package/dist/providers/createProvidersHandlers.js +229 -0
- package/dist/providers/index.d.ts +47 -0
- package/dist/{voice/client → providers}/index.js +15 -6
- package/dist/providers/registryUsage.d.ts +48 -0
- package/dist/providers/registryUsage.js +236 -0
- package/dist/records/createIndexRecord.d.ts +42 -0
- package/dist/records/createIndexRecord.js +185 -0
- package/dist/records/createRecordsRouter.d.ts +61 -0
- package/dist/records/createRecordsRouter.js +330 -0
- package/dist/records/createSearchRecords.d.ts +51 -0
- package/dist/records/createSearchRecords.js +134 -0
- package/dist/{voice/filters → records}/index.d.ts +6 -6
- package/dist/{voice/filters → records}/index.js +6 -6
- package/dist/records/maintenance.d.ts +33 -0
- package/dist/records/maintenance.js +166 -0
- package/dist/records/runCallRecords.d.ts +48 -0
- package/dist/records/runCallRecords.js +49 -0
- package/dist/{events/createPerCallCache.d.ts → records/stores.d.ts} +4 -7
- package/dist/{voice/handlers/utils/isDtmf.js → records/stores.js} +9 -3
- package/dist/records/types.d.ts +104 -0
- package/dist/regions/configSync.d.ts +130 -0
- package/dist/regions/configSync.js +316 -0
- package/dist/regions/createRegionsRouter.d.ts +151 -0
- package/dist/regions/createRegionsRouter.js +391 -0
- package/dist/regions/endpoints.d.ts +41 -0
- package/dist/regions/endpoints.js +90 -0
- package/dist/regions/enrollmentToken.d.ts +41 -0
- package/dist/regions/enrollmentToken.js +94 -0
- package/dist/regions/httpAuth.d.ts +39 -0
- package/dist/regions/httpAuth.js +78 -0
- package/dist/regions/ids.d.ts +15 -0
- package/dist/regions/ids.js +81 -0
- package/dist/{voice/client → regions}/index.d.ts +17 -6
- package/dist/regions/index.js +51 -0
- package/dist/regions/link.d.ts +17 -0
- package/dist/regions/link.js +170 -0
- package/dist/regions/natsAuth.d.ts +41 -0
- package/dist/regions/natsAuth.js +64 -0
- package/dist/regions/natsJwt.d.ts +23 -0
- package/dist/regions/natsJwt.js +26 -0
- package/dist/regions/relay.d.ts +45 -0
- package/dist/regions/relay.js +203 -0
- package/dist/regions/relayHttp.d.ts +7 -0
- package/dist/regions/relayHttp.js +107 -0
- package/dist/regions/relaySlots.d.ts +18 -0
- package/dist/regions/relaySlots.js +118 -0
- package/dist/regions/runRegions.d.ts +111 -0
- package/dist/regions/runRegions.js +235 -0
- package/dist/regions/service.d.ts +129 -0
- package/dist/regions/service.js +558 -0
- package/dist/regions/sources.d.ts +20 -0
- package/dist/regions/sources.js +191 -0
- package/dist/regions/status.d.ts +35 -0
- package/dist/regions/status.js +63 -0
- package/dist/regions/types.d.ts +123 -0
- package/dist/regions/types.js +41 -0
- package/dist/{voice/integrations/getSttConfig.d.ts → regions/withConfigChangeHook.d.ts} +13 -7
- package/dist/regions/withConfigChangeHook.js +44 -0
- package/dist/secrets/createGetFnUtil.d.ts +2 -2
- package/dist/session/createSessionRouter.d.ts +49 -0
- package/dist/session/createSessionRouter.js +206 -0
- package/dist/{voice/handlers/dial → session}/index.d.ts +1 -1
- package/dist/{voice/handlers/dial → session}/index.js +1 -1
- package/dist/usage/buildService.d.ts +16 -0
- package/dist/{voice/integrations/getTtsConfig.js → usage/buildService.js} +13 -7
- package/dist/{voice/tts/utils/convertUlawToPCM16.d.ts → usage/createGetUsage.d.ts} +7 -6
- package/dist/usage/createGetUsage.js +118 -0
- package/dist/usage/ingestUsage.d.ts +7 -0
- package/dist/usage/ingestUsage.js +87 -0
- package/dist/usage/publishRecordedUsage.d.ts +52 -0
- package/dist/usage/publishRecordedUsage.js +103 -0
- package/dist/{utils/createHandleDialEventsWithNats.d.ts → usage/publishUsage.d.ts} +10 -4
- package/dist/usage/publishUsage.js +50 -0
- package/dist/usage/rebuildUsage.d.ts +48 -0
- package/dist/usage/rebuildUsage.js +104 -0
- package/dist/usage/runUsageConsumer.d.ts +22 -0
- package/dist/usage/runUsageConsumer.js +78 -0
- package/dist/usage/snapshotStorage.d.ts +14 -0
- package/dist/usage/snapshotStorage.js +95 -0
- package/dist/{voice/integrations/getTtsConfig.d.ts → usage/types.d.ts} +17 -6
- package/dist/utils/createCheckNumberPreconditions.js +4 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/dist/voice/stt/Deepgram.d.ts +4 -57
- package/dist/voice/stt/Deepgram.js +15 -286
- package/dist/voice/stt/Google.d.ts +4 -15
- package/dist/voice/stt/Google.js +7 -103
- package/dist/voice/stt/types.d.ts +2 -38
- package/dist/voice/stt/types.js +25 -3
- package/dist/voice/tts/Azure.d.ts +4 -34
- package/dist/voice/tts/Azure.js +25 -105
- package/dist/voice/tts/Deepgram.d.ts +4 -38
- package/dist/voice/tts/Deepgram.js +25 -82
- package/dist/voice/tts/ElevenLabs.d.ts +4 -18
- package/dist/voice/tts/ElevenLabs.js +6 -97
- package/dist/voice/tts/Google.d.ts +4 -38
- package/dist/voice/tts/Google.js +25 -91
- package/dist/webhooks/createWebhooksHandlers.d.ts +37 -0
- package/dist/webhooks/createWebhooksHandlers.js +217 -0
- package/dist/webhooks/index.d.ts +37 -0
- package/dist/webhooks/index.js +51 -0
- package/dist/webhooks/lostCalls.d.ts +49 -0
- package/dist/webhooks/lostCalls.js +147 -0
- package/dist/webhooks/nodeCallEvents.d.ts +73 -0
- package/dist/webhooks/nodeCallEvents.js +177 -0
- package/dist/webhooks/runWebhookFanout.d.ts +44 -0
- package/dist/webhooks/runWebhookFanout.js +202 -0
- package/package.json +21 -31
- package/dist/applications/utils/applicationWithEncodedStruct.d.ts +0 -3
- package/dist/applications/utils/applicationWithEncodedStruct.js +0 -50
- package/dist/applications/utils/convertToApplicationData.js +0 -37
- package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +0 -786
- package/dist/applications/validation/assistantWithoutApiKeySchema.js +0 -35
- package/dist/applications/validation/createValidationSchema.d.ts +0 -1474
- package/dist/applications/validation/createValidationSchema.js +0 -67
- package/dist/applications/validation/prepareForValidation.d.ts +0 -21
- package/dist/applications/validation/prepareForValidation.js +0 -35
- package/dist/applications/validation/speechValidators.d.ts +0 -47
- package/dist/applications/validation/speechValidators.js +0 -50
- package/dist/applications/validation/validOrThrow.d.ts +0 -21
- package/dist/applications/validation/validOrThrow.js +0 -15
- package/dist/calls/createFetchCalls.d.ts +0 -22
- package/dist/calls/createFetchCalls.js +0 -88
- package/dist/calls/createFetchSingleCall.d.ts +0 -22
- package/dist/calls/influxdb.d.ts +0 -2
- package/dist/calls/runCallManager.d.ts +0 -8
- package/dist/calls/runCallManager.js +0 -75
- package/dist/core/buildWelcomeDemoService.js +0 -97
- package/dist/core/upsertDefaultPeer.d.ts +0 -2
- package/dist/events/amdResultCache.d.ts +0 -23
- package/dist/events/amdResultCache.js +0 -35
- package/dist/events/createInfluxDbPub.d.ts +0 -13
- package/dist/events/createInfluxDbPub.js +0 -89
- package/dist/events/createPerCallCache.js +0 -46
- package/dist/events/mapCallDirectionToEnum.d.ts +0 -21
- package/dist/events/mapCallDirectionToEnum.js +0 -37
- package/dist/events/nats.d.ts +0 -10
- package/dist/events/nats.js +0 -82
- package/dist/events/transformEvent.d.ts +0 -2
- package/dist/events/transformEvent.js +0 -87
- package/dist/events/types.d.ts +0 -26
- package/dist/utils/createHandleDialEventsWithNats.js +0 -24
- package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +0 -23
- package/dist/utils/createHandleDialEventsWithVoiceClient.js +0 -27
- package/dist/utils/getIntegrationsFromFile.d.ts +0 -2
- package/dist/utils/getIntegrationsFromFile.js +0 -49
- package/dist/utils/mapDialStatus.d.ts +0 -21
- package/dist/utils/mapDialStatus.js +0 -38
- package/dist/voice/VoiceDispatcher.d.ts +0 -21
- package/dist/voice/VoiceDispatcher.js +0 -122
- package/dist/voice/amd/mapAsteriskAmd.d.ts +0 -38
- package/dist/voice/amd/mapAsteriskAmd.js +0 -68
- package/dist/voice/client/AudioSocketHandler.d.ts +0 -38
- package/dist/voice/client/AudioSocketHandler.js +0 -70
- package/dist/voice/client/AuthorizationHandler.d.ts +0 -13
- package/dist/voice/client/AuthorizationHandler.js +0 -78
- package/dist/voice/client/ExternalMediaHandler.d.ts +0 -32
- package/dist/voice/client/ExternalMediaHandler.js +0 -59
- package/dist/voice/client/GrpcClientHandler.d.ts +0 -36
- package/dist/voice/client/SpeechHandler.d.ts +0 -60
- package/dist/voice/client/SpeechHandler.js +0 -120
- package/dist/voice/client/VoiceClientImpl.d.ts +0 -79
- package/dist/voice/client/VoiceClientImpl.js +0 -198
- package/dist/voice/connectToAri.d.ts +0 -2
- package/dist/voice/connectToAri.js +0 -81
- package/dist/voice/createCreateVoiceClient.d.ts +0 -9
- package/dist/voice/createCreateVoiceClient.js +0 -97
- package/dist/voice/errors/ChannelVarNotFoundError.d.ts +0 -23
- package/dist/voice/errors/ChannelVarNotFoundError.js +0 -10
- package/dist/voice/errors/MethodNotImplementedError.d.ts +0 -22
- package/dist/voice/errors/MethodNotImplementedError.js +0 -27
- package/dist/voice/filters/AudioFilterFactory.d.ts +0 -35
- package/dist/voice/filters/AudioFilterFactory.js +0 -94
- package/dist/voice/filters/aiCoustics/createAiCousticsFilter.d.ts +0 -64
- package/dist/voice/filters/aiCoustics/createAiCousticsFilter.js +0 -252
- package/dist/voice/filters/aiCoustics/types.d.ts +0 -45
- package/dist/voice/filters/aiCoustics/types.js +0 -29
- package/dist/voice/filters/createAudioFilterChain.d.ts +0 -9
- package/dist/voice/filters/createAudioFilterChain.js +0 -171
- package/dist/voice/filters/createAudioFilterSession.d.ts +0 -15
- package/dist/voice/filters/createAudioFilterSession.js +0 -114
- package/dist/voice/filters/pcm.d.ts +0 -21
- package/dist/voice/filters/pcm.js +0 -37
- package/dist/voice/filters/types.d.ts +0 -61
- package/dist/voice/filters/types.js +0 -26
- package/dist/voice/handlers/createAnswerHandler.d.ts +0 -23
- package/dist/voice/handlers/createAnswerHandler.js +0 -24
- package/dist/voice/handlers/createHangupHandler.d.ts +0 -23
- package/dist/voice/handlers/createHangupHandler.js +0 -28
- package/dist/voice/handlers/createMuteHandler.d.ts +0 -4
- package/dist/voice/handlers/createMuteHandler.js +0 -27
- package/dist/voice/handlers/createPlayDtmfHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlayDtmfHandler.js +0 -27
- package/dist/voice/handlers/createPlayHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlayHandler.js +0 -33
- package/dist/voice/handlers/createPlaybackControlHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlaybackControlHandler.js +0 -62
- package/dist/voice/handlers/createRecordHandler.d.ts +0 -4
- package/dist/voice/handlers/createRecordHandler.js +0 -58
- package/dist/voice/handlers/createSayHandler.d.ts +0 -4
- package/dist/voice/handlers/createSayHandler.js +0 -31
- package/dist/voice/handlers/createSetAudioFiltersHandler.d.ts +0 -11
- package/dist/voice/handlers/createSetAudioFiltersHandler.js +0 -74
- package/dist/voice/handlers/createStopSayHandler.d.ts +0 -3
- package/dist/voice/handlers/createStopSayHandler.js +0 -34
- package/dist/voice/handlers/createStreamGatherHandler.d.ts +0 -3
- package/dist/voice/handlers/createStreamGatherHandler.js +0 -74
- package/dist/voice/handlers/createStreamHandler.d.ts +0 -3
- package/dist/voice/handlers/createStreamHandler.js +0 -70
- package/dist/voice/handlers/createUnmuteHandler.d.ts +0 -4
- package/dist/voice/handlers/createUnmuteHandler.js +0 -27
- package/dist/voice/handlers/dial/createDialHandler.d.ts +0 -23
- package/dist/voice/handlers/dial/createDialHandler.js +0 -78
- package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +0 -24
- package/dist/voice/handlers/dial/handleChannelLeftBridge.js +0 -29
- package/dist/voice/handlers/dial/handleStasisEnd.d.ts +0 -21
- package/dist/voice/handlers/dial/handleStasisEnd.js +0 -19
- package/dist/voice/handlers/dial/handleStasisStart.d.ts +0 -27
- package/dist/voice/handlers/dial/handleStasisStart.js +0 -52
- package/dist/voice/handlers/dial/recordChannel.d.ts +0 -22
- package/dist/voice/handlers/gather/createGatherHandler.d.ts +0 -3
- package/dist/voice/handlers/gather/createGatherHandler.js +0 -86
- package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +0 -26
- package/dist/voice/handlers/gather/getTimeoutPromise.js +0 -18
- package/dist/voice/handlers/index.d.ts +0 -33
- package/dist/voice/handlers/index.js +0 -49
- package/dist/voice/handlers/utils/awaitForPlaybackFinished.d.ts +0 -21
- package/dist/voice/handlers/utils/awaitForPlaybackFinished.js +0 -25
- package/dist/voice/handlers/utils/awaitForRecordingFinished.d.ts +0 -5
- package/dist/voice/handlers/utils/awaitForRecordingFinished.js +0 -53
- package/dist/voice/handlers/utils/isDtmf.d.ts +0 -20
- package/dist/voice/handlers/utils/textChunksByClause.d.ts +0 -2
- package/dist/voice/handlers/utils/textChunksByClause.js +0 -41
- package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.d.ts +0 -2
- package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.js +0 -34
- package/dist/voice/handlers/utils/withErrorHandling.d.ts +0 -22
- package/dist/voice/handlers/utils/withErrorHandling.js +0 -38
- package/dist/voice/integrations/ApplicationNotFoundError.d.ts +0 -22
- package/dist/voice/integrations/ApplicationNotFoundError.js +0 -28
- package/dist/voice/integrations/createCreateContainer.d.ts +0 -4
- package/dist/voice/integrations/createCreateContainer.js +0 -76
- package/dist/voice/integrations/getSttConfig.js +0 -30
- package/dist/voice/integrations/index.js +0 -35
- package/dist/voice/integrations/types.d.ts +0 -29
- package/dist/voice/stt/AbstractSpeechToText.d.ts +0 -33
- package/dist/voice/stt/AbstractSpeechToText.js +0 -19
- package/dist/voice/stt/SpeechToTextFactory.d.ts +0 -9
- package/dist/voice/stt/SpeechToTextFactory.js +0 -43
- package/dist/voice/transcribeOnConnection.d.ts +0 -35
- package/dist/voice/transcribeOnConnection.js +0 -91
- package/dist/voice/tts/AbstractTextToSpeech.d.ts +0 -40
- package/dist/voice/tts/AbstractTextToSpeech.js +0 -50
- package/dist/voice/tts/TextToSpeechFactory.d.ts +0 -8
- package/dist/voice/tts/TextToSpeechFactory.js +0 -47
- package/dist/voice/tts/types.d.ts +0 -48
- package/dist/voice/tts/types.js +0 -2
- package/dist/voice/tts/utils/convertUlawToPCM16.js +0 -40
- package/dist/voice/tts/utils/createChunkedSynthesisStream.d.ts +0 -28
- package/dist/voice/tts/utils/createChunkedSynthesisStream.js +0 -78
- package/dist/voice/tts/utils/createErrorStream.d.ts +0 -21
- package/dist/voice/tts/utils/createErrorStream.js +0 -28
- package/dist/voice/tts/utils/index.d.ts +0 -23
- package/dist/voice/tts/utils/index.js +0 -39
- package/dist/voice/tts/utils/isSsml.d.ts +0 -20
- package/dist/voice/tts/utils/isSsml.js +0 -25
- package/dist/voice/tts/utils/streamToBuffer.d.ts +0 -20
- package/dist/voice/tts/utils/streamToBuffer.js +0 -60
- package/dist/voice/types/ari.d.ts +0 -43
- package/dist/voice/types/ari.js +0 -48
- package/dist/voice/types/index.d.ts +0 -20
- package/dist/voice/types/index.js +0 -36
- package/dist/voice/types/voice.d.ts +0 -67
- package/dist/voice/types/voice.js +0 -2
- package/dist/voice/utils/VoiceServiceClientConstructor.d.ts +0 -3
- package/dist/voice/utils/createExternalMediaConfig.d.ts +0 -12
- package/dist/voice/utils/createExternalMediaConfig.js +0 -37
- package/dist/voice/utils/createGetChannelVar.d.ts +0 -22
- package/dist/voice/utils/createGetChannelVar.js +0 -27
- package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +0 -22
- package/dist/voice/utils/createGetChannelVarWithoutThrow.js +0 -26
- package/dist/voice/utils/index.d.ts +0 -22
- package/dist/voice/utils/index.js +0 -38
- /package/dist/{events → records}/types.js +0 -0
- /package/dist/{voice/integrations → usage}/types.js +0 -0
package/dist/voice/tts/Azure.js
CHANGED
|
@@ -1,115 +1,35 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.
|
|
3
|
+
exports.Azure = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 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
|
+
*/
|
|
46
22
|
const common_1 = require("@fonoster/common");
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const createChunkedSynthesisStream_1 = require("./utils/createChunkedSynthesisStream");
|
|
51
|
-
const isSsml_1 = require("./utils/isSsml");
|
|
52
|
-
const ENGINE_NAME = "tts.azure";
|
|
53
|
-
exports.ENGINE_NAME = ENGINE_NAME;
|
|
54
|
-
class Azure extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
55
|
-
constructor(config) {
|
|
56
|
-
super();
|
|
57
|
-
this.engineName = ENGINE_NAME;
|
|
58
|
-
this.OUTPUT_FORMAT = "sln16";
|
|
59
|
-
this.CACHING_FIELDS = ["voice"];
|
|
60
|
-
this.config = config;
|
|
61
|
-
}
|
|
62
|
-
synthesize(text, options) {
|
|
63
|
-
this.logSynthesisRequest(text, options);
|
|
64
|
-
const ref = this.createMediaReference();
|
|
65
|
-
const { subscriptionKey, serviceRegion } = this.config.credentials;
|
|
66
|
-
const voice = options.voice || this.config.config.voice;
|
|
67
|
-
const speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);
|
|
68
|
-
speechConfig.speechSynthesisVoiceName = voice;
|
|
69
|
-
speechConfig.speechSynthesisOutputFormat =
|
|
70
|
-
sdk.SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm;
|
|
71
|
-
const stream = (0, createChunkedSynthesisStream_1.createChunkedSynthesisStream)(text, (chunkText) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
const synthesizer = new sdk.SpeechSynthesizer(speechConfig);
|
|
73
|
-
const isSSML = (0, isSsml_1.isSsml)(chunkText);
|
|
74
|
-
const func = isSSML ? "speakSsmlAsync" : "speakTextAsync";
|
|
75
|
-
try {
|
|
76
|
-
const audioData = yield new Promise((resolve, reject) => {
|
|
77
|
-
const audioChunks = [];
|
|
78
|
-
synthesizer[func](chunkText, (result) => {
|
|
79
|
-
if (result.reason === sdk.ResultReason.SynthesizingAudioCompleted) {
|
|
80
|
-
audioChunks.push(Buffer.from(result.audioData));
|
|
81
|
-
resolve(Buffer.concat(audioChunks));
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
reject(new Error("Speech synthesis canceled: " + result.errorDetails));
|
|
85
|
-
}
|
|
86
|
-
synthesizer.close();
|
|
87
|
-
}, (err) => {
|
|
88
|
-
synthesizer.close();
|
|
89
|
-
reject(new Error(err));
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
// Ignore the first 44 bytes of the response to avoid the WAV header
|
|
93
|
-
return audioData.subarray(44);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
// Make sure synthesizer is closed in case of error
|
|
97
|
-
synthesizer.close();
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
}));
|
|
101
|
-
return { ref, stream };
|
|
102
|
-
}
|
|
23
|
+
const zod_1 = require("zod");
|
|
24
|
+
/** Azure TTS config and credential schemas (application validation only). */
|
|
25
|
+
class Azure {
|
|
103
26
|
static getConfigValidationSchema() {
|
|
104
|
-
return z.object({
|
|
105
|
-
voice: z.nativeEnum(common_1.AzureVoice, { message: "Invalid Azure voice" })
|
|
27
|
+
return zod_1.z.object({
|
|
28
|
+
voice: zod_1.z.nativeEnum(common_1.AzureVoice, { message: "Invalid Azure voice" })
|
|
106
29
|
});
|
|
107
30
|
}
|
|
108
31
|
static getCredentialsValidationSchema() {
|
|
109
|
-
return z.object({
|
|
110
|
-
subscriptionKey: z.string(),
|
|
111
|
-
serviceRegion: z.string()
|
|
112
|
-
});
|
|
32
|
+
return zod_1.z.object({ subscriptionKey: zod_1.z.string(), serviceRegion: zod_1.z.string() });
|
|
113
33
|
}
|
|
114
34
|
}
|
|
115
35
|
exports.Azure = Azure;
|
|
@@ -1,41 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 { Readable } from "stream";
|
|
20
|
-
import { DeepgramClient } from "@deepgram/sdk";
|
|
21
|
-
import * as z from "zod";
|
|
22
|
-
import { AbstractTextToSpeech } from "./AbstractTextToSpeech";
|
|
23
|
-
import { DeepgramTtsConfig, SynthOptions } from "./types";
|
|
24
|
-
declare const ENGINE_NAME = "tts.deepgram";
|
|
25
|
-
declare class Deepgram extends AbstractTextToSpeech<typeof ENGINE_NAME> {
|
|
26
|
-
client: DeepgramClient;
|
|
27
|
-
engineConfig: DeepgramTtsConfig;
|
|
28
|
-
readonly engineName = "tts.deepgram";
|
|
29
|
-
protected readonly OUTPUT_FORMAT = "sln16";
|
|
30
|
-
protected readonly CACHING_FIELDS: string[];
|
|
31
|
-
protected readonly AUDIO_ENCODING: "linear16";
|
|
32
|
-
protected readonly SAMPLE_RATE_HERTZ = 8000;
|
|
33
|
-
constructor(config: DeepgramTtsConfig);
|
|
34
|
-
synthesize(text: string, options: SynthOptions): {
|
|
35
|
-
ref: string;
|
|
36
|
-
stream: Readable;
|
|
37
|
-
};
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Deepgram TTS config and credential schemas (application validation only). */
|
|
3
|
+
declare class Deepgram {
|
|
38
4
|
static getConfigValidationSchema(): z.Schema;
|
|
39
5
|
static getCredentialsValidationSchema(): z.Schema;
|
|
40
6
|
}
|
|
41
|
-
export { Deepgram
|
|
7
|
+
export { Deepgram };
|
|
@@ -1,92 +1,35 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.
|
|
46
|
-
|
|
3
|
+
exports.Deepgram = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 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
|
+
*/
|
|
47
22
|
const common_1 = require("@fonoster/common");
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const streamToBuffer_1 = require("./utils/streamToBuffer");
|
|
52
|
-
const ENGINE_NAME = "tts.deepgram";
|
|
53
|
-
exports.ENGINE_NAME = ENGINE_NAME;
|
|
54
|
-
class Deepgram extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
55
|
-
constructor(config) {
|
|
56
|
-
super();
|
|
57
|
-
this.engineName = ENGINE_NAME;
|
|
58
|
-
this.OUTPUT_FORMAT = "sln16";
|
|
59
|
-
this.CACHING_FIELDS = ["voice"];
|
|
60
|
-
this.AUDIO_ENCODING = "linear16";
|
|
61
|
-
this.SAMPLE_RATE_HERTZ = 8000;
|
|
62
|
-
this.client = (0, sdk_1.createClient)(config.credentials.apiKey);
|
|
63
|
-
this.engineConfig = config;
|
|
64
|
-
}
|
|
65
|
-
synthesize(text, options) {
|
|
66
|
-
this.logSynthesisRequest(text, options);
|
|
67
|
-
const { voice } = this.engineConfig.config;
|
|
68
|
-
const ref = this.createMediaReference();
|
|
69
|
-
const selectedVoice = voice || common_1.DeepgramVoice.AURA_ASTERIA_EN;
|
|
70
|
-
const stream = (0, createChunkedSynthesisStream_1.createChunkedSynthesisStream)(text, (chunkText) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const response = yield this.client.speak.request({ text: chunkText }, {
|
|
72
|
-
model: selectedVoice,
|
|
73
|
-
encoding: this.AUDIO_ENCODING,
|
|
74
|
-
sample_rate: this.SAMPLE_RATE_HERTZ,
|
|
75
|
-
container: "none"
|
|
76
|
-
});
|
|
77
|
-
return (yield (0, streamToBuffer_1.streamToBuffer)(yield response.getStream()));
|
|
78
|
-
}));
|
|
79
|
-
return { ref, stream };
|
|
80
|
-
}
|
|
23
|
+
const zod_1 = require("zod");
|
|
24
|
+
/** Deepgram TTS config and credential schemas (application validation only). */
|
|
25
|
+
class Deepgram {
|
|
81
26
|
static getConfigValidationSchema() {
|
|
82
|
-
return z.object({
|
|
83
|
-
voice: z.nativeEnum(common_1.DeepgramVoice, { message: "Invalid Deepgram voice" })
|
|
27
|
+
return zod_1.z.object({
|
|
28
|
+
voice: zod_1.z.nativeEnum(common_1.DeepgramVoice, { message: "Invalid Deepgram voice" })
|
|
84
29
|
});
|
|
85
30
|
}
|
|
86
31
|
static getCredentialsValidationSchema() {
|
|
87
|
-
return z.object({
|
|
88
|
-
apiKey: z.string()
|
|
89
|
-
});
|
|
32
|
+
return zod_1.z.object({ apiKey: zod_1.z.string() });
|
|
90
33
|
}
|
|
91
34
|
}
|
|
92
35
|
exports.Deepgram = Deepgram;
|
|
@@ -16,24 +16,10 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
import { AbstractTextToSpeech } from "./AbstractTextToSpeech";
|
|
23
|
-
import { ElevenLabsTtsConfig, SynthOptions } from "./types";
|
|
24
|
-
declare const ENGINE_NAME = "tts.elevenlabs";
|
|
25
|
-
declare class ElevenLabs extends AbstractTextToSpeech<typeof ENGINE_NAME> {
|
|
26
|
-
client: ElevenLabsClient;
|
|
27
|
-
engineConfig: ElevenLabsTtsConfig;
|
|
28
|
-
readonly engineName = "tts.elevenlabs";
|
|
29
|
-
protected readonly OUTPUT_FORMAT = "sln16";
|
|
30
|
-
protected readonly CACHING_FIELDS: string[];
|
|
31
|
-
constructor(config: ElevenLabsTtsConfig);
|
|
32
|
-
synthesize(text: string, options: SynthOptions): {
|
|
33
|
-
ref: string;
|
|
34
|
-
stream: Readable;
|
|
35
|
-
};
|
|
19
|
+
import { z } from "zod";
|
|
20
|
+
/** ElevenLabs TTS config and credential schemas (application validation only). */
|
|
21
|
+
declare class ElevenLabs {
|
|
36
22
|
static getConfigValidationSchema(): z.Schema;
|
|
37
23
|
static getCredentialsValidationSchema(): z.Schema;
|
|
38
24
|
}
|
|
39
|
-
export {
|
|
25
|
+
export { ElevenLabs };
|
|
@@ -1,48 +1,6 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.ElevenLabs =
|
|
3
|
+
exports.ElevenLabs = void 0;
|
|
46
4
|
/**
|
|
47
5
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
48
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -61,63 +19,14 @@ exports.ElevenLabs = exports.ENGINE_NAME = void 0;
|
|
|
61
19
|
* See the License for the specific language governing permissions and
|
|
62
20
|
* limitations under the License.
|
|
63
21
|
*/
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const z = __importStar(require("zod"));
|
|
68
|
-
const AbstractTextToSpeech_1 = require("./AbstractTextToSpeech");
|
|
69
|
-
const convertUlawToPCM16_1 = require("./utils/convertUlawToPCM16");
|
|
70
|
-
const createChunkedSynthesisStream_1 = require("./utils/createChunkedSynthesisStream");
|
|
71
|
-
const streamToBuffer_1 = require("./utils/streamToBuffer");
|
|
72
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
73
|
-
const ENGINE_NAME = "tts.elevenlabs";
|
|
74
|
-
exports.ENGINE_NAME = ENGINE_NAME;
|
|
75
|
-
class ElevenLabs extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
76
|
-
constructor(config) {
|
|
77
|
-
super();
|
|
78
|
-
this.engineName = ENGINE_NAME;
|
|
79
|
-
this.OUTPUT_FORMAT = "sln16"; // TODO: Ask the team at ElevenLabs to provde PCM 16-bit at 8kHz
|
|
80
|
-
this.CACHING_FIELDS = ["voice", "text"];
|
|
81
|
-
this.client = new elevenlabs_1.ElevenLabsClient(config.credentials);
|
|
82
|
-
this.engineConfig = config;
|
|
83
|
-
}
|
|
84
|
-
synthesize(text, options) {
|
|
85
|
-
this.logSynthesisRequest(text, options);
|
|
86
|
-
const { voice, model } = this.engineConfig.config;
|
|
87
|
-
const ref = this.createMediaReference();
|
|
88
|
-
const stream = (0, createChunkedSynthesisStream_1.createChunkedSynthesisStream)(text, (chunkText) => __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
try {
|
|
90
|
-
const response = yield this.client.generate({
|
|
91
|
-
stream: true,
|
|
92
|
-
voice,
|
|
93
|
-
text: chunkText,
|
|
94
|
-
model_id: model !== null && model !== void 0 ? model : "eleven_flash_v2_5",
|
|
95
|
-
output_format: "ulaw_8000",
|
|
96
|
-
// TODO: Make this configurable
|
|
97
|
-
optimize_streaming_latency: 2
|
|
98
|
-
}, {
|
|
99
|
-
maxRetries: 3
|
|
100
|
-
});
|
|
101
|
-
const ulawBuffer = yield (0, streamToBuffer_1.streamToBuffer)(response);
|
|
102
|
-
const pcmBuffer = yield (0, convertUlawToPCM16_1.convertUlawToPCM16)(stream_1.Readable.from(ulawBuffer));
|
|
103
|
-
return pcmBuffer;
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
logger.error(`error in ElevenLabs synthesis: ${error.message}`, {
|
|
107
|
-
stack: error.stack
|
|
108
|
-
});
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}));
|
|
112
|
-
return { ref, stream };
|
|
113
|
-
}
|
|
22
|
+
const zod_1 = require("zod");
|
|
23
|
+
/** ElevenLabs TTS config and credential schemas (application validation only). */
|
|
24
|
+
class ElevenLabs {
|
|
114
25
|
static getConfigValidationSchema() {
|
|
115
|
-
return z.object({});
|
|
26
|
+
return zod_1.z.object({});
|
|
116
27
|
}
|
|
117
28
|
static getCredentialsValidationSchema() {
|
|
118
|
-
return z.object({
|
|
119
|
-
apiKey: z.string()
|
|
120
|
-
});
|
|
29
|
+
return zod_1.z.object({ apiKey: zod_1.z.string() });
|
|
121
30
|
}
|
|
122
31
|
}
|
|
123
32
|
exports.ElevenLabs = ElevenLabs;
|
|
@@ -1,41 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 { Readable } from "stream";
|
|
20
|
-
import { TextToSpeechClient } from "@google-cloud/text-to-speech";
|
|
21
|
-
import * as z from "zod";
|
|
22
|
-
import { AbstractTextToSpeech } from "./AbstractTextToSpeech";
|
|
23
|
-
import { GoogleTtsConfig, SynthOptions } from "./types";
|
|
24
|
-
declare const ENGINE_NAME = "tts.google";
|
|
25
|
-
declare class Google extends AbstractTextToSpeech<typeof ENGINE_NAME> {
|
|
26
|
-
client: TextToSpeechClient;
|
|
27
|
-
engineConfig: GoogleTtsConfig;
|
|
28
|
-
readonly engineName = "tts.google";
|
|
29
|
-
protected readonly OUTPUT_FORMAT = "sln16";
|
|
30
|
-
protected readonly CACHING_FIELDS: string[];
|
|
31
|
-
protected readonly AUDIO_ENCODING: "LINEAR16";
|
|
32
|
-
protected readonly SAMPLE_RATE_HERTZ = 8000;
|
|
33
|
-
constructor(config: GoogleTtsConfig);
|
|
34
|
-
synthesize(text: string, options: SynthOptions): {
|
|
35
|
-
ref: string;
|
|
36
|
-
stream: Readable;
|
|
37
|
-
};
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Google TTS config and credential schemas (application validation only). */
|
|
3
|
+
declare class Google {
|
|
38
4
|
static getConfigValidationSchema(): z.Schema;
|
|
39
5
|
static getCredentialsValidationSchema(): z.Schema;
|
|
40
6
|
}
|
|
41
|
-
export {
|
|
7
|
+
export { Google };
|
package/dist/voice/tts/Google.js
CHANGED
|
@@ -1,103 +1,37 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.Google =
|
|
3
|
+
exports.Google = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2025 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
|
+
*/
|
|
46
22
|
const common_1 = require("@fonoster/common");
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const createChunkedSynthesisStream_1 = require("./utils/createChunkedSynthesisStream");
|
|
51
|
-
const isSsml_1 = require("./utils/isSsml");
|
|
52
|
-
const ENGINE_NAME = "tts.google";
|
|
53
|
-
exports.ENGINE_NAME = ENGINE_NAME;
|
|
54
|
-
class Google extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
55
|
-
constructor(config) {
|
|
56
|
-
super();
|
|
57
|
-
this.engineName = ENGINE_NAME;
|
|
58
|
-
this.OUTPUT_FORMAT = "sln16";
|
|
59
|
-
this.CACHING_FIELDS = ["voice"];
|
|
60
|
-
this.AUDIO_ENCODING = "LINEAR16";
|
|
61
|
-
this.SAMPLE_RATE_HERTZ = 8000;
|
|
62
|
-
this.client = new text_to_speech_1.TextToSpeechClient(config);
|
|
63
|
-
this.engineConfig = config;
|
|
64
|
-
}
|
|
65
|
-
synthesize(text, options) {
|
|
66
|
-
this.logSynthesisRequest(text, options);
|
|
67
|
-
const ref = this.createMediaReference();
|
|
68
|
-
const { voice } = this.engineConfig.config;
|
|
69
|
-
const lang = `${voice.split("-")[0]}-${voice.split("-")[1]}`;
|
|
70
|
-
const stream = (0, createChunkedSynthesisStream_1.createChunkedSynthesisStream)(text, (chunkText) => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const request = {
|
|
72
|
-
input: (0, isSsml_1.isSsml)(chunkText) ? { ssml: chunkText } : { text: chunkText },
|
|
73
|
-
audioConfig: {
|
|
74
|
-
audioEncoding: this.AUDIO_ENCODING,
|
|
75
|
-
sampleRateHertz: this.SAMPLE_RATE_HERTZ
|
|
76
|
-
},
|
|
77
|
-
voice: {
|
|
78
|
-
languageCode: lang,
|
|
79
|
-
name: voice
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const [response] = yield this.client.synthesizeSpeech(request);
|
|
83
|
-
const audioContent = response.audioContent;
|
|
84
|
-
// Ignore the first 44 bytes of the response to avoid the WAV header
|
|
85
|
-
return audioContent.subarray(44);
|
|
86
|
-
}));
|
|
87
|
-
return { ref, stream };
|
|
88
|
-
}
|
|
23
|
+
const zod_1 = require("zod");
|
|
24
|
+
/** Google TTS config and credential schemas (application validation only). */
|
|
25
|
+
class Google {
|
|
89
26
|
static getConfigValidationSchema() {
|
|
90
|
-
return z.object({
|
|
91
|
-
voice: z
|
|
27
|
+
return zod_1.z.object({
|
|
28
|
+
voice: zod_1.z
|
|
92
29
|
.nativeEnum(common_1.GoogleVoice, { message: "Invalid Google voice" })
|
|
93
30
|
.optional()
|
|
94
31
|
});
|
|
95
32
|
}
|
|
96
33
|
static getCredentialsValidationSchema() {
|
|
97
|
-
return z.object({
|
|
98
|
-
client_email: z.string(),
|
|
99
|
-
private_key: z.string()
|
|
100
|
-
});
|
|
34
|
+
return zod_1.z.object({ client_email: zod_1.z.string(), private_key: zod_1.z.string() });
|
|
101
35
|
}
|
|
102
36
|
}
|
|
103
37
|
exports.Google = Google;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { GrpcErrorMessage } from "@fonoster/common";
|
|
2
|
+
export type WebhooksDb = any;
|
|
3
|
+
export type WebhooksConfig = {
|
|
4
|
+
/** Plain http:// endpoints (local testing only). */
|
|
5
|
+
allowInsecureUrls?: boolean;
|
|
6
|
+
/** Private destinations endpoints may use (default FONOSTER_ALLOWED_DESTINATIONS, RV-B2). */
|
|
7
|
+
allowedDestinations?: string[];
|
|
8
|
+
/** How long the previous secret keeps verifying after a rotation (W4: 24 h). */
|
|
9
|
+
rotationWindowMs?: number;
|
|
10
|
+
now?: () => number;
|
|
11
|
+
};
|
|
12
|
+
export declare function createWebhooksHandlers(db: WebhooksDb, config?: WebhooksConfig): {
|
|
13
|
+
createWebhook: (call: {
|
|
14
|
+
request: unknown;
|
|
15
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
16
|
+
listWebhooks: (call: {
|
|
17
|
+
request: unknown;
|
|
18
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
19
|
+
getWebhook: (call: {
|
|
20
|
+
request: unknown;
|
|
21
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
22
|
+
updateWebhook: (call: {
|
|
23
|
+
request: unknown;
|
|
24
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
25
|
+
deleteWebhook: (call: {
|
|
26
|
+
request: unknown;
|
|
27
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
28
|
+
rotateWebhookSecret: (call: {
|
|
29
|
+
request: unknown;
|
|
30
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
31
|
+
listWebhookDeliveries: (call: {
|
|
32
|
+
request: unknown;
|
|
33
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
34
|
+
resendWebhookDelivery: (call: {
|
|
35
|
+
request: unknown;
|
|
36
|
+
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
37
|
+
};
|