@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
|
@@ -1,49 +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.
|
|
46
|
-
exports.buildTranscribeConfig = buildTranscribeConfig;
|
|
3
|
+
exports.Deepgram = void 0;
|
|
47
4
|
/**
|
|
48
5
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
49
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -62,262 +19,34 @@ exports.buildTranscribeConfig = buildTranscribeConfig;
|
|
|
62
19
|
* See the License for the specific language governing permissions and
|
|
63
20
|
* limitations under the License.
|
|
64
21
|
*/
|
|
65
|
-
const stream_1 = require("stream");
|
|
66
22
|
const common_1 = require("@fonoster/common");
|
|
67
|
-
const
|
|
68
|
-
const z = __importStar(require("zod"));
|
|
69
|
-
const AbstractSpeechToText_1 = require("./AbstractSpeechToText");
|
|
23
|
+
const zod_1 = require("zod");
|
|
70
24
|
const types_1 = require("./types");
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} = require("@deepgram/sdk"); // Why Deepgram :(
|
|
74
|
-
const ENGINE_NAME = "stt.deepgram";
|
|
75
|
-
exports.ENGINE_NAME = ENGINE_NAME;
|
|
76
|
-
// Nova-3 detects English, Spanish and eight other languages; Nova-2 only
|
|
77
|
-
// English + Spanish. The phonecall/conversationalai variants are English-only.
|
|
78
|
-
const MULTILINGUAL_MODELS = [types_1.DeepgramModel.NOVA_3, types_1.DeepgramModel.NOVA_2];
|
|
79
|
-
// Deepgram's recommended endpointing for code-switching (its default is 10ms)
|
|
80
|
-
const MULTILINGUAL_ENDPOINTING_MS = 100;
|
|
81
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
82
|
-
class Deepgram extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
83
|
-
constructor(config) {
|
|
84
|
-
super(config);
|
|
85
|
-
this.engineName = ENGINE_NAME;
|
|
86
|
-
this.client = createClient(config.credentials.apiKey);
|
|
87
|
-
this.engineConfig = config;
|
|
88
|
-
}
|
|
89
|
-
streamTranscribe(stream) {
|
|
90
|
-
const connection = this.client.listen.live(buildTranscribeConfig(this.engineConfig.config));
|
|
91
|
-
const out = new stream_1.Stream();
|
|
92
|
-
// Track last transcript for UtteranceEnd fallback
|
|
93
|
-
// According to Deepgram docs: "If you receive an UtteranceEnd event without a
|
|
94
|
-
// preceding speech_final: true, it's advisable to process the last-received
|
|
95
|
-
// transcript as a complete utterance."
|
|
96
|
-
// UtteranceEnd fires after finalized words, so we store the last finalized transcript
|
|
97
|
-
// but also keep any transcript as a fallback
|
|
98
|
-
let lastFinalizedTranscript = null;
|
|
99
|
-
let lastFinalizedTranscriptTime = 0;
|
|
100
|
-
let lastAnyTranscript = null;
|
|
101
|
-
let lastAnyTranscriptTime = 0;
|
|
102
|
-
// Add error handler immediately to catch any connection errors
|
|
103
|
-
connection.on(LiveTranscriptionEvents.Error, (err) => {
|
|
104
|
-
logger.error("error on Deepgram connection", { err });
|
|
105
|
-
// Emit error properly for handling upstream
|
|
106
|
-
out.emit("error", new Error("Speech recognition service error"));
|
|
107
|
-
try {
|
|
108
|
-
connection.destroy();
|
|
109
|
-
}
|
|
110
|
-
catch (destroyErr) {
|
|
111
|
-
logger.error("error destroying connection", { destroyErr });
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
connection.on(LiveTranscriptionEvents.Open, () => {
|
|
115
|
-
stream.on("data", (chunk) => {
|
|
116
|
-
try {
|
|
117
|
-
connection.send(chunk);
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
logger.error("error sending chunk to Deepgram", { err });
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
connection.on(LiveTranscriptionEvents.Transcript, (data) => {
|
|
124
|
-
var _a, _b, _c;
|
|
125
|
-
const transcript = (_c = (_b = (_a = data.channel) === null || _a === void 0 ? void 0 : _a.alternatives) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.transcript;
|
|
126
|
-
const hasTranscript = !!transcript;
|
|
127
|
-
const isFinal = data.is_final === true;
|
|
128
|
-
const speechFinal = data.speech_final === true;
|
|
129
|
-
// Store any transcript for UtteranceEnd fallback
|
|
130
|
-
if (hasTranscript) {
|
|
131
|
-
lastAnyTranscript = transcript;
|
|
132
|
-
lastAnyTranscriptTime = Date.now();
|
|
133
|
-
// Store finalized transcripts separately (preferred for UtteranceEnd)
|
|
134
|
-
if (isFinal || speechFinal) {
|
|
135
|
-
lastFinalizedTranscript = transcript;
|
|
136
|
-
lastFinalizedTranscriptTime = Date.now();
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
// Process transcript if it has content and is final
|
|
140
|
-
// Check both speech_final (primary) and is_final (backup)
|
|
141
|
-
if (!hasTranscript || (!speechFinal && !isFinal)) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
const words = data.channel.alternatives[0].words || [];
|
|
145
|
-
const responseTime = words.length > 0
|
|
146
|
-
? (words.reduce((acc, word) => acc + (word.end - word.start), 0) *
|
|
147
|
-
1000) /
|
|
148
|
-
words.length
|
|
149
|
-
: 0;
|
|
150
|
-
logger.verbose("transcribe result", {
|
|
151
|
-
speech: transcript,
|
|
152
|
-
responseTime,
|
|
153
|
-
isFinal,
|
|
154
|
-
speechFinal
|
|
155
|
-
});
|
|
156
|
-
out.emit("data", {
|
|
157
|
-
speech: transcript,
|
|
158
|
-
responseTime
|
|
159
|
-
});
|
|
160
|
-
// Clear transcripts after processing (they've been emitted)
|
|
161
|
-
lastFinalizedTranscript = null;
|
|
162
|
-
lastAnyTranscript = null;
|
|
163
|
-
});
|
|
164
|
-
// CRITICAL: Handle UtteranceEnd events (fallback when speech_final never becomes true)
|
|
165
|
-
// This is Deepgram's recommended fallback mechanism for noisy environments
|
|
166
|
-
// UtteranceEnd requires: interim_results=true and utterance_end_ms parameter
|
|
167
|
-
// UtteranceEnd fires after finalized words, so prefer lastFinalizedTranscript
|
|
168
|
-
connection.on(LiveTranscriptionEvents.UtteranceEnd, (data) => {
|
|
169
|
-
// Prefer finalized transcript, fall back to any transcript
|
|
170
|
-
const transcriptToUse = lastFinalizedTranscript || lastAnyTranscript;
|
|
171
|
-
const transcriptTime = lastFinalizedTranscript
|
|
172
|
-
? lastFinalizedTranscriptTime
|
|
173
|
-
: lastAnyTranscriptTime;
|
|
174
|
-
if (transcriptToUse) {
|
|
175
|
-
// Use last_word_end from UtteranceEnd event if available for more accurate timing
|
|
176
|
-
// Otherwise fall back to time since last transcript
|
|
177
|
-
const lastWordEnd = data === null || data === void 0 ? void 0 : data.last_word_end;
|
|
178
|
-
const responseTime = lastWordEnd
|
|
179
|
-
? lastWordEnd * 1000 // Convert seconds to milliseconds
|
|
180
|
-
: transcriptTime
|
|
181
|
-
? Date.now() - transcriptTime
|
|
182
|
-
: 0;
|
|
183
|
-
logger.info("Deepgram UtteranceEnd - processing last transcript", {
|
|
184
|
-
speech: transcriptToUse,
|
|
185
|
-
responseTime,
|
|
186
|
-
lastWordEnd: lastWordEnd,
|
|
187
|
-
wasFinalized: !!lastFinalizedTranscript
|
|
188
|
-
});
|
|
189
|
-
out.emit("data", {
|
|
190
|
-
speech: transcriptToUse,
|
|
191
|
-
responseTime
|
|
192
|
-
});
|
|
193
|
-
// Clear transcripts after processing
|
|
194
|
-
lastFinalizedTranscript = null;
|
|
195
|
-
lastAnyTranscript = null;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
logger.warn("Deepgram UtteranceEnd received but no last transcript available");
|
|
199
|
-
}
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
// Handle stream errors and cleanup
|
|
203
|
-
stream.on("error", (err) => {
|
|
204
|
-
logger.warn("error on input stream", { err });
|
|
205
|
-
// Instead of emitting an error, just end the stream with a message
|
|
206
|
-
out.emit("data", {
|
|
207
|
-
speech: "Error with audio input stream",
|
|
208
|
-
responseTime: 0
|
|
209
|
-
});
|
|
210
|
-
out.emit("end");
|
|
211
|
-
try {
|
|
212
|
-
connection.destroy();
|
|
213
|
-
}
|
|
214
|
-
catch (destroyErr) {
|
|
215
|
-
logger.warn("error destroying connection", { destroyErr });
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
stream.on("end", () => {
|
|
219
|
-
try {
|
|
220
|
-
connection.destroy();
|
|
221
|
-
}
|
|
222
|
-
catch (err) {
|
|
223
|
-
logger.error("error destroying connection on stream end", { err });
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
return out;
|
|
227
|
-
}
|
|
228
|
-
transcribe(stream) {
|
|
229
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
return new Promise((resolve, reject) => {
|
|
231
|
-
const startTime = performance.now();
|
|
232
|
-
const connection = this.client.listen.live(buildTranscribeConfig(this.engineConfig.config));
|
|
233
|
-
stream.on("data", (chunk) => {
|
|
234
|
-
connection.send(chunk);
|
|
235
|
-
});
|
|
236
|
-
connection.on(LiveTranscriptionEvents.Open, () => {
|
|
237
|
-
connection.on(LiveTranscriptionEvents.Transcript, (data) => {
|
|
238
|
-
if (data.channel.alternatives[0].transcript && data.speech_final) {
|
|
239
|
-
const result = {
|
|
240
|
-
speech: data.channel.alternatives[0].transcript,
|
|
241
|
-
isFinal: true,
|
|
242
|
-
responseTime: performance.now() - startTime
|
|
243
|
-
};
|
|
244
|
-
logger.verbose("transcribe result", {
|
|
245
|
-
speech: result.speech,
|
|
246
|
-
responseTime: result.responseTime
|
|
247
|
-
});
|
|
248
|
-
resolve(result);
|
|
249
|
-
connection.destroy();
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
connection.on(LiveTranscriptionEvents.Error, (err) => {
|
|
253
|
-
logger.warn("error on Deepgram connection", { err });
|
|
254
|
-
reject(err);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
stream.on("end", () => {
|
|
258
|
-
try {
|
|
259
|
-
connection.destroy();
|
|
260
|
-
}
|
|
261
|
-
catch (destroyErr) {
|
|
262
|
-
logger.error("error destroying connection", { destroyErr });
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
stream.on("error", (err) => {
|
|
266
|
-
try {
|
|
267
|
-
connection.destroy();
|
|
268
|
-
}
|
|
269
|
-
catch (destroyErr) {
|
|
270
|
-
logger.error("error destroying connection", { destroyErr });
|
|
271
|
-
}
|
|
272
|
-
reject(err);
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
}
|
|
25
|
+
/** Deepgram STT config and credential schemas (application validation only). */
|
|
26
|
+
class Deepgram {
|
|
277
27
|
static getConfigValidationSchema() {
|
|
278
|
-
return z
|
|
28
|
+
return zod_1.z
|
|
279
29
|
.object({
|
|
280
|
-
smartFormat: z.boolean().optional(),
|
|
281
|
-
noDelay: z.boolean().optional(),
|
|
282
|
-
languageCode: z
|
|
283
|
-
.union([z.nativeEnum(common_1.VoiceLanguage), z.literal(types_1.DEEPGRAM_MULTILINGUAL)], { errorMap: () => ({ message: common_1.Messages.VALID_LANGUAGE_CODE }) })
|
|
30
|
+
smartFormat: zod_1.z.boolean().optional(),
|
|
31
|
+
noDelay: zod_1.z.boolean().optional(),
|
|
32
|
+
languageCode: zod_1.z
|
|
33
|
+
.union([zod_1.z.nativeEnum(common_1.VoiceLanguage), zod_1.z.literal(types_1.DEEPGRAM_MULTILINGUAL)], { errorMap: () => ({ message: common_1.Messages.VALID_LANGUAGE_CODE }) })
|
|
284
34
|
.optional(),
|
|
285
|
-
model: z
|
|
35
|
+
model: zod_1.z
|
|
286
36
|
.nativeEnum(types_1.DeepgramModel, { message: "Invalid Deepgram model" })
|
|
287
37
|
.optional(),
|
|
288
|
-
interimResults: z.boolean().optional(),
|
|
289
|
-
utteranceEndMs: z.number().int().min(1000).max(5000).optional()
|
|
38
|
+
interimResults: zod_1.z.boolean().optional(),
|
|
39
|
+
utteranceEndMs: zod_1.z.number().int().min(1000).max(5000).optional()
|
|
290
40
|
})
|
|
291
41
|
.refine((config) => config.languageCode !== types_1.DEEPGRAM_MULTILINGUAL ||
|
|
292
42
|
!config.model ||
|
|
293
|
-
MULTILINGUAL_MODELS.includes(config.model), {
|
|
294
|
-
message: `Language "${types_1.DEEPGRAM_MULTILINGUAL}" requires one of these models: ${MULTILINGUAL_MODELS.join(", ")}`,
|
|
43
|
+
types_1.MULTILINGUAL_MODELS.includes(config.model), {
|
|
44
|
+
message: `Language "${types_1.DEEPGRAM_MULTILINGUAL}" requires one of these models: ${types_1.MULTILINGUAL_MODELS.join(", ")}`,
|
|
295
45
|
path: ["model"]
|
|
296
46
|
});
|
|
297
47
|
}
|
|
298
48
|
static getCredentialsValidationSchema() {
|
|
299
|
-
return z.object({
|
|
300
|
-
apiKey: z.string()
|
|
301
|
-
});
|
|
49
|
+
return zod_1.z.object({ apiKey: zod_1.z.string() });
|
|
302
50
|
}
|
|
303
51
|
}
|
|
304
52
|
exports.Deepgram = Deepgram;
|
|
305
|
-
function buildTranscribeConfig(config) {
|
|
306
|
-
// UtteranceEnd requires interim_results to be enabled
|
|
307
|
-
// Default to true to enable UtteranceEnd fallback mechanism
|
|
308
|
-
const interimResults = config.interimResults !== false;
|
|
309
|
-
// Default utterance_end_ms to 1000ms (minimum required value)
|
|
310
|
-
// This enables UtteranceEnd events as a fallback when speech_final never becomes true
|
|
311
|
-
const utteranceEndMs = config.utteranceEndMs || 1000;
|
|
312
|
-
const isMultilingual = config.languageCode === types_1.DEEPGRAM_MULTILINGUAL;
|
|
313
|
-
return Object.assign(Object.assign(Object.assign({}, config), {
|
|
314
|
-
// The phonecall default is English-only, so multilingual needs its own
|
|
315
|
-
model: config.model ||
|
|
316
|
-
(isMultilingual ? types_1.DeepgramModel.NOVA_3 : types_1.DeepgramModel.NOVA_2_PHONECALL), language: config.languageCode || common_1.VoiceLanguage.EN_US, encoding: "linear16", sample_rate: 16000, channels: 1, smart_format: config.smartFormat !== false,
|
|
317
|
-
// This needs to be set to true to avoid delays while using smart_format
|
|
318
|
-
no_delay: config.noDelay !== false,
|
|
319
|
-
// REQUIRED for UtteranceEnd: interim_results must be true
|
|
320
|
-
interim_results: interimResults,
|
|
321
|
-
// REQUIRED for UtteranceEnd: utterance_end_ms parameter
|
|
322
|
-
utterance_end_ms: utteranceEndMs }), (isMultilingual && { endpointing: MULTILINGUAL_ENDPOINTING_MS }));
|
|
323
|
-
}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { SpeechToText } from "../types";
|
|
5
|
-
import { AbstractSpeechToText } from "./AbstractSpeechToText";
|
|
6
|
-
import { GoogleSttConfig, SpeechResult, StreamSpeech } from "./types";
|
|
7
|
-
declare const ENGINE_NAME = "stt.google";
|
|
8
|
-
declare class Google extends AbstractSpeechToText<typeof ENGINE_NAME> implements SpeechToText {
|
|
9
|
-
client: SpeechClient;
|
|
10
|
-
engineConfig: GoogleSttConfig;
|
|
11
|
-
readonly engineName = "stt.google";
|
|
12
|
-
constructor(config: GoogleSttConfig);
|
|
13
|
-
streamTranscribe(_: Stream): StreamSpeech;
|
|
14
|
-
transcribe(stream: Stream): Promise<SpeechResult>;
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Google STT config and credential schemas (application validation only). */
|
|
3
|
+
declare class Google {
|
|
15
4
|
static getConfigValidationSchema(): z.Schema;
|
|
16
5
|
static getCredentialsValidationSchema(): z.Schema;
|
|
17
6
|
}
|
|
18
|
-
export {
|
|
7
|
+
export { Google };
|
package/dist/voice/stt/Google.js
CHANGED
|
@@ -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.Google =
|
|
3
|
+
exports.Google = void 0;
|
|
46
4
|
/**
|
|
47
5
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
48
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -61,73 +19,19 @@ exports.Google = 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 perf_hooks_1 = require("perf_hooks");
|
|
65
22
|
const common_1 = require("@fonoster/common");
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const ENGINE_NAME = "stt.google";
|
|
70
|
-
exports.ENGINE_NAME = ENGINE_NAME;
|
|
71
|
-
class Google extends AbstractSpeechToText_1.AbstractSpeechToText {
|
|
72
|
-
constructor(config) {
|
|
73
|
-
super(config);
|
|
74
|
-
this.engineName = ENGINE_NAME;
|
|
75
|
-
this.client = new speech_1.SpeechClient(config);
|
|
76
|
-
this.engineConfig = config;
|
|
77
|
-
}
|
|
78
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
-
streamTranscribe(_) {
|
|
80
|
-
// Not implemented
|
|
81
|
-
throw new Error("Stream Transcribe not implemented for Google Engine");
|
|
82
|
-
}
|
|
83
|
-
transcribe(stream) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const startTime = perf_hooks_1.performance.now();
|
|
86
|
-
const languageCode = this.engineConfig.config.languageCode || common_1.VoiceLanguage.EN_US;
|
|
87
|
-
const audioConfig = {
|
|
88
|
-
interimResults: false,
|
|
89
|
-
config: {
|
|
90
|
-
encoding: "LINEAR16",
|
|
91
|
-
sampleRateHertz: 16000,
|
|
92
|
-
languageCode
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
return new Promise((resolve, reject) => {
|
|
96
|
-
const recognizeStream = this.client
|
|
97
|
-
.streamingRecognize(audioConfig)
|
|
98
|
-
.on("error", (e) => reject(e))
|
|
99
|
-
.on("data", (data) => {
|
|
100
|
-
var _a;
|
|
101
|
-
const responseTime = perf_hooks_1.performance.now() - startTime;
|
|
102
|
-
if ((_a = data.results[0]) === null || _a === void 0 ? void 0 : _a.alternatives[0]) {
|
|
103
|
-
const result = {
|
|
104
|
-
speech: data.results[0].alternatives[0].transcript,
|
|
105
|
-
isFinal: true,
|
|
106
|
-
responseTime
|
|
107
|
-
};
|
|
108
|
-
resolve(result);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
resolve({ speech: "", isFinal: true, responseTime });
|
|
112
|
-
}
|
|
113
|
-
recognizeStream.destroy();
|
|
114
|
-
});
|
|
115
|
-
stream.pipe(recognizeStream);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
}
|
|
23
|
+
const zod_1 = require("zod");
|
|
24
|
+
/** Google STT config and credential schemas (application validation only). */
|
|
25
|
+
class Google {
|
|
119
26
|
static getConfigValidationSchema() {
|
|
120
|
-
return z.object({
|
|
121
|
-
languageCode: z
|
|
27
|
+
return zod_1.z.object({
|
|
28
|
+
languageCode: zod_1.z
|
|
122
29
|
.nativeEnum(common_1.VoiceLanguage, { message: common_1.Messages.VALID_LANGUAGE_CODE })
|
|
123
30
|
.optional()
|
|
124
31
|
});
|
|
125
32
|
}
|
|
126
33
|
static getCredentialsValidationSchema() {
|
|
127
|
-
return z.object({
|
|
128
|
-
client_email: z.string(),
|
|
129
|
-
private_key: z.string()
|
|
130
|
-
});
|
|
34
|
+
return zod_1.z.object({ client_email: zod_1.z.string(), private_key: zod_1.z.string() });
|
|
131
35
|
}
|
|
132
36
|
}
|
|
133
37
|
exports.Google = Google;
|
|
@@ -16,29 +16,6 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { VoiceLanguage } from "@fonoster/common";
|
|
20
|
-
type SpeechResult = {
|
|
21
|
-
speech: string;
|
|
22
|
-
isFinal: boolean;
|
|
23
|
-
responseTime: number;
|
|
24
|
-
};
|
|
25
|
-
type StreamSpeech = {
|
|
26
|
-
on(events: string, callback: (result: SpeechResult) => void): void;
|
|
27
|
-
};
|
|
28
|
-
type SttConfig = {
|
|
29
|
-
config: {
|
|
30
|
-
languageCode: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
type GoogleSttConfig = {
|
|
34
|
-
config: {
|
|
35
|
-
languageCode: VoiceLanguage;
|
|
36
|
-
};
|
|
37
|
-
credentials: {
|
|
38
|
-
client_email: string;
|
|
39
|
-
private_key: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
19
|
declare enum DeepgramModel {
|
|
43
20
|
NOVA_3 = "nova-3",
|
|
44
21
|
NOVA_2 = "nova-2",
|
|
@@ -46,18 +23,5 @@ declare enum DeepgramModel {
|
|
|
46
23
|
NOVA_2_CONVERSATIONALAI = "nova-2-conversationalai"
|
|
47
24
|
}
|
|
48
25
|
declare const DEEPGRAM_MULTILINGUAL = "multi";
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
config: {
|
|
52
|
-
languageCode: DeepgramLanguage;
|
|
53
|
-
model: DeepgramModel;
|
|
54
|
-
smartFormat: boolean;
|
|
55
|
-
noDelay: boolean;
|
|
56
|
-
interimResults?: boolean;
|
|
57
|
-
utteranceEndMs?: number;
|
|
58
|
-
};
|
|
59
|
-
credentials: {
|
|
60
|
-
apiKey: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
export { DEEPGRAM_MULTILINGUAL, DeepgramLanguage, DeepgramModel, DeepgramSttConfig, GoogleSttConfig, SpeechResult, StreamSpeech, SttConfig };
|
|
26
|
+
declare const MULTILINGUAL_MODELS: DeepgramModel[];
|
|
27
|
+
export { DEEPGRAM_MULTILINGUAL, DeepgramModel, MULTILINGUAL_MODELS };
|
package/dist/voice/stt/types.js
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeepgramModel = exports.DEEPGRAM_MULTILINGUAL = void 0;
|
|
3
|
+
exports.MULTILINGUAL_MODELS = exports.DeepgramModel = exports.DEEPGRAM_MULTILINGUAL = 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
|
+
*/
|
|
22
|
+
// What is left of the apiserver's speech engines after the rebuild (cleanbreak CB-B4): the
|
|
23
|
+
// config and credential schemas that application validation still checks. Speech runs in the
|
|
24
|
+
// appbridge now (add-provider-registry).
|
|
4
25
|
var DeepgramModel;
|
|
5
26
|
(function (DeepgramModel) {
|
|
6
27
|
DeepgramModel["NOVA_3"] = "nova-3";
|
|
@@ -8,7 +29,8 @@ var DeepgramModel;
|
|
|
8
29
|
DeepgramModel["NOVA_2_PHONECALL"] = "nova-2-phonecall";
|
|
9
30
|
DeepgramModel["NOVA_2_CONVERSATIONALAI"] = "nova-2-conversationalai";
|
|
10
31
|
})(DeepgramModel || (exports.DeepgramModel = DeepgramModel = {}));
|
|
11
|
-
// Deepgram's code-switching mode: transcribes speech that mixes languages
|
|
12
|
-
// (e.g. a caller who answers "Hello" on a Spanish call). Nova-3 and Nova-2.
|
|
32
|
+
// Deepgram's code-switching mode: transcribes speech that mixes languages. Nova-3 and Nova-2.
|
|
13
33
|
const DEEPGRAM_MULTILINGUAL = "multi";
|
|
14
34
|
exports.DEEPGRAM_MULTILINGUAL = DEEPGRAM_MULTILINGUAL;
|
|
35
|
+
const MULTILINGUAL_MODELS = [DeepgramModel.NOVA_3, DeepgramModel.NOVA_2];
|
|
36
|
+
exports.MULTILINGUAL_MODELS = MULTILINGUAL_MODELS;
|
|
@@ -1,37 +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 * as z from "zod";
|
|
21
|
-
import { AbstractTextToSpeech } from "./AbstractTextToSpeech";
|
|
22
|
-
import { AzureTTSConfig, SynthOptions } from "./types";
|
|
23
|
-
declare const ENGINE_NAME = "tts.azure";
|
|
24
|
-
declare class Azure extends AbstractTextToSpeech<typeof ENGINE_NAME> {
|
|
25
|
-
config: AzureTTSConfig;
|
|
26
|
-
readonly engineName = "tts.azure";
|
|
27
|
-
protected readonly OUTPUT_FORMAT = "sln16";
|
|
28
|
-
protected readonly CACHING_FIELDS: string[];
|
|
29
|
-
constructor(config: AzureTTSConfig);
|
|
30
|
-
synthesize(text: string, options: SynthOptions): {
|
|
31
|
-
ref: string;
|
|
32
|
-
stream: Readable;
|
|
33
|
-
};
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Azure TTS config and credential schemas (application validation only). */
|
|
3
|
+
declare class Azure {
|
|
34
4
|
static getConfigValidationSchema(): z.Schema;
|
|
35
5
|
static getCredentialsValidationSchema(): z.Schema;
|
|
36
6
|
}
|
|
37
|
-
export { Azure
|
|
7
|
+
export { Azure };
|