@pipedog/core 0.0.0 → 0.1.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/LICENSE +25 -0
- package/NOTICE +9 -0
- package/dist/adapters/base_llm_adapter.d.ts +266 -0
- package/dist/adapters/base_llm_adapter.js +489 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.js +8 -0
- package/dist/adapters/schemas/direct_function.d.ts +202 -0
- package/dist/adapters/schemas/direct_function.js +302 -0
- package/dist/adapters/schemas/function_schema.d.ts +67 -0
- package/dist/adapters/schemas/function_schema.js +72 -0
- package/dist/adapters/schemas/index.d.ts +2 -0
- package/dist/adapters/schemas/index.js +8 -0
- package/dist/adapters/schemas/tools_schema.d.ts +57 -0
- package/dist/adapters/schemas/tools_schema.js +79 -0
- package/dist/adapters/services/index.d.ts +2 -0
- package/dist/adapters/services/index.js +8 -0
- package/dist/adapters/services/open_ai_adapter.d.ts +147 -0
- package/dist/adapters/services/open_ai_adapter.js +250 -0
- package/dist/audio/dtmf/dtmf_data.d.ts +3 -0
- package/dist/audio/dtmf/dtmf_data.js +22 -0
- package/dist/audio/dtmf/index.d.ts +2 -0
- package/dist/audio/dtmf/index.js +8 -0
- package/dist/audio/dtmf/types.d.ts +31 -0
- package/dist/audio/dtmf/types.js +35 -0
- package/dist/audio/dtmf/utils.d.ts +13 -0
- package/dist/audio/dtmf/utils.js +62 -0
- package/dist/audio/filters/base_audio_filter.d.ts +51 -0
- package/dist/audio/filters/base_audio_filter.js +17 -0
- package/dist/audio/filters/index.d.ts +2 -0
- package/dist/audio/filters/index.js +8 -0
- package/dist/audio/index.d.ts +2 -0
- package/dist/audio/index.js +8 -0
- package/dist/audio/krisp_instance.d.ts +95 -0
- package/dist/audio/krisp_instance.js +229 -0
- package/dist/audio/mixers/base_audio_mixer.d.ts +56 -0
- package/dist/audio/mixers/base_audio_mixer.js +16 -0
- package/dist/audio/mixers/index.d.ts +2 -0
- package/dist/audio/mixers/index.js +8 -0
- package/dist/audio/resamplers/base_audio_resampler.d.ts +46 -0
- package/dist/audio/resamplers/base_audio_resampler.js +35 -0
- package/dist/audio/resamplers/index.d.ts +2 -0
- package/dist/audio/resamplers/index.js +8 -0
- package/dist/audio/resamplers/resampy_resampler.d.ts +10 -0
- package/dist/audio/resamplers/resampy_resampler.js +15 -0
- package/dist/audio/resamplers/soxr_resampler.d.ts +54 -0
- package/dist/audio/resamplers/soxr_resampler.js +69 -0
- package/dist/audio/resamplers/soxr_stream_resampler.d.ts +75 -0
- package/dist/audio/resamplers/soxr_stream_resampler.js +146 -0
- package/dist/audio/turn/base_turn_analyzer.d.ts +84 -0
- package/dist/audio/turn/base_turn_analyzer.js +61 -0
- package/dist/audio/turn/index.d.ts +2 -0
- package/dist/audio/turn/index.js +8 -0
- package/dist/audio/turn/smart_turn/_whisper_features.d.ts +30 -0
- package/dist/audio/turn/smart_turn/_whisper_features.js +225 -0
- package/dist/audio/turn/smart_turn/base_smart_turn.d.ts +94 -0
- package/dist/audio/turn/smart_turn/base_smart_turn.js +239 -0
- package/dist/audio/turn/smart_turn/local_smart_turn_v3.d.ts +76 -0
- package/dist/audio/turn/smart_turn/local_smart_turn_v3.js +143 -0
- package/dist/audio/utils.d.ts +224 -0
- package/dist/audio/utils.js +634 -0
- package/dist/audio/vad/data/index.d.ts +2 -0
- package/dist/audio/vad/data/index.js +8 -0
- package/dist/audio/vad/index.d.ts +2 -0
- package/dist/audio/vad/index.js +8 -0
- package/dist/audio/vad/vad_analyzer.d.ts +126 -0
- package/dist/audio/vad/vad_analyzer.js +211 -0
- package/dist/audio/vad/vad_controller.d.ts +143 -0
- package/dist/audio/vad/vad_controller.js +228 -0
- package/dist/audio/volume.d.ts +38 -0
- package/dist/audio/volume.js +75 -0
- package/dist/bus/adapters/base.d.ts +35 -0
- package/dist/bus/adapters/base.js +19 -0
- package/dist/bus/adapters/index.d.ts +10 -0
- package/dist/bus/adapters/index.js +15 -0
- package/dist/bus/adapters/llm_context_adapter.d.ts +36 -0
- package/dist/bus/adapters/llm_context_adapter.js +82 -0
- package/dist/bus/adapters/tools_schema_adapter.d.ts +25 -0
- package/dist/bus/adapters/tools_schema_adapter.js +70 -0
- package/dist/bus/bridge_processor.d.ts +111 -0
- package/dist/bus/bridge_processor.js +166 -0
- package/dist/bus/bus.d.ts +110 -0
- package/dist/bus/bus.js +200 -0
- package/dist/bus/index.d.ts +22 -0
- package/dist/bus/index.js +27 -0
- package/dist/bus/local/async_queue.d.ts +12 -0
- package/dist/bus/local/async_queue.js +21 -0
- package/dist/bus/local/index.d.ts +3 -0
- package/dist/bus/local/index.js +8 -0
- package/dist/bus/messages.d.ts +378 -0
- package/dist/bus/messages.js +357 -0
- package/dist/bus/network/index.d.ts +16 -0
- package/dist/bus/network/index.js +21 -0
- package/dist/bus/queue.d.ts +27 -0
- package/dist/bus/queue.js +51 -0
- package/dist/bus/serializers/base.d.ts +25 -0
- package/dist/bus/serializers/base.js +14 -0
- package/dist/bus/serializers/index.d.ts +9 -0
- package/dist/bus/serializers/index.js +14 -0
- package/dist/bus/serializers/json.d.ts +77 -0
- package/dist/bus/serializers/json.js +367 -0
- package/dist/bus/subscriber.d.ts +46 -0
- package/dist/bus/subscriber.js +27 -0
- package/dist/bus/ui/index.d.ts +3 -0
- package/dist/bus/ui/index.js +8 -0
- package/dist/bus/ui/messages.d.ts +186 -0
- package/dist/bus/ui/messages.js +171 -0
- package/dist/classifiers/base_classifier.d.ts +263 -0
- package/dist/classifiers/base_classifier.js +346 -0
- package/dist/classifiers/cloudflare/clef/classifier.d.ts +70 -0
- package/dist/classifiers/cloudflare/clef/classifier.js +204 -0
- package/dist/classifiers/cloudflare/clef/client.d.ts +104 -0
- package/dist/classifiers/cloudflare/clef/client.js +234 -0
- package/dist/classifiers/cloudflare/clef/index.d.ts +2 -0
- package/dist/classifiers/cloudflare/clef/index.js +8 -0
- package/dist/classifiers/cloudflare/index.d.ts +2 -0
- package/dist/classifiers/cloudflare/index.js +8 -0
- package/dist/classifiers/http_client.d.ts +70 -0
- package/dist/classifiers/http_client.js +161 -0
- package/dist/classifiers/index.d.ts +2 -0
- package/dist/classifiers/index.js +8 -0
- package/dist/classifiers/jev/classifier.d.ts +8 -0
- package/dist/classifiers/jev/classifier.js +13 -0
- package/dist/classifiers/jev/client.d.ts +8 -0
- package/dist/classifiers/jev/client.js +13 -0
- package/dist/classifiers/jev/index.d.ts +2 -0
- package/dist/classifiers/jev/index.js +8 -0
- package/dist/classifiers/llm/classifier.d.ts +72 -0
- package/dist/classifiers/llm/classifier.js +304 -0
- package/dist/classifiers/llm/index.d.ts +2 -0
- package/dist/classifiers/llm/index.js +8 -0
- package/dist/classifiers/openai/decisions/classifier.d.ts +77 -0
- package/dist/classifiers/openai/decisions/classifier.js +241 -0
- package/dist/classifiers/openai/decisions/client.d.ts +108 -0
- package/dist/classifiers/openai/decisions/client.js +234 -0
- package/dist/classifiers/openai/decisions/index.d.ts +2 -0
- package/dist/classifiers/openai/decisions/index.js +8 -0
- package/dist/classifiers/openai/index.d.ts +2 -0
- package/dist/classifiers/openai/index.js +8 -0
- package/dist/classifiers/typesafe/index.d.ts +2 -0
- package/dist/classifiers/typesafe/index.js +8 -0
- package/dist/classifiers/typesafe/jev/classifier.d.ts +70 -0
- package/dist/classifiers/typesafe/jev/classifier.js +220 -0
- package/dist/classifiers/typesafe/jev/client.d.ts +105 -0
- package/dist/classifiers/typesafe/jev/client.js +233 -0
- package/dist/classifiers/typesafe/jev/index.d.ts +2 -0
- package/dist/classifiers/typesafe/jev/index.js +8 -0
- package/dist/clocks/base_clock.d.ts +13 -0
- package/dist/clocks/base_clock.js +14 -0
- package/dist/clocks/index.d.ts +2 -0
- package/dist/clocks/index.js +8 -0
- package/dist/clocks/system_clock.d.ts +15 -0
- package/dist/clocks/system_clock.js +25 -0
- package/dist/frames/frames.d.ts +2533 -0
- package/dist/frames/frames.js +2485 -0
- package/dist/frames/index.d.ts +2 -0
- package/dist/frames/index.js +8 -0
- package/dist/frames/protobufs/frames_pb2.d.ts +229 -0
- package/dist/frames/protobufs/frames_pb2.js +466 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +56 -0
- package/dist/metrics/index.d.ts +2 -0
- package/dist/metrics/index.js +8 -0
- package/dist/metrics/metrics.d.ts +276 -0
- package/dist/metrics/metrics.js +254 -0
- package/dist/observers/base_observer.d.ts +173 -0
- package/dist/observers/base_observer.js +151 -0
- package/dist/observers/error_observer.d.ts +75 -0
- package/dist/observers/error_observer.js +87 -0
- package/dist/observers/function_call_observer.d.ts +157 -0
- package/dist/observers/function_call_observer.js +222 -0
- package/dist/observers/index.d.ts +2 -0
- package/dist/observers/index.js +8 -0
- package/dist/observers/loggers/debug_log_observer.d.ts +91 -0
- package/dist/observers/loggers/debug_log_observer.js +228 -0
- package/dist/observers/loggers/index.d.ts +2 -0
- package/dist/observers/loggers/index.js +8 -0
- package/dist/observers/loggers/llm_log_observer.d.ts +24 -0
- package/dist/observers/loggers/llm_log_observer.js +110 -0
- package/dist/observers/loggers/metrics_log_observer.d.ts +85 -0
- package/dist/observers/loggers/metrics_log_observer.js +186 -0
- package/dist/observers/loggers/transcription_log_observer.d.ts +23 -0
- package/dist/observers/loggers/transcription_log_observer.js +74 -0
- package/dist/observers/service_metrics_observer.d.ts +168 -0
- package/dist/observers/service_metrics_observer.js +236 -0
- package/dist/observers/speaking_observer.d.ts +104 -0
- package/dist/observers/speaking_observer.js +150 -0
- package/dist/observers/startup_timing_observer.d.ts +221 -0
- package/dist/observers/startup_timing_observer.js +365 -0
- package/dist/observers/turn_tracking_observer.d.ts +78 -0
- package/dist/observers/turn_tracking_observer.js +189 -0
- package/dist/observers/user_bot_latency_observer.d.ts +411 -0
- package/dist/observers/user_bot_latency_observer.js +974 -0
- package/dist/pipeline/base_pipeline.d.ts +49 -0
- package/dist/pipeline/base_pipeline.js +101 -0
- package/dist/pipeline/capabilities.d.ts +76 -0
- package/dist/pipeline/capabilities.js +97 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +8 -0
- package/dist/pipeline/job_context.d.ts +317 -0
- package/dist/pipeline/job_context.js +450 -0
- package/dist/pipeline/job_decorator.d.ts +54 -0
- package/dist/pipeline/job_decorator.js +92 -0
- package/dist/pipeline/llm_switcher.d.ts +84 -0
- package/dist/pipeline/llm_switcher.js +107 -0
- package/dist/pipeline/llm_with_backend.d.ts +435 -0
- package/dist/pipeline/llm_with_backend.js +806 -0
- package/dist/pipeline/parallel_pipeline.d.ts +83 -0
- package/dist/pipeline/parallel_pipeline.js +200 -0
- package/dist/pipeline/pipeline.d.ts +126 -0
- package/dist/pipeline/pipeline.js +196 -0
- package/dist/pipeline/service_switcher.d.ts +287 -0
- package/dist/pipeline/service_switcher.js +509 -0
- package/dist/pipeline/sync_parallel_pipeline.d.ts +192 -0
- package/dist/pipeline/sync_parallel_pipeline.js +387 -0
- package/dist/pipeline/worker.d.ts +814 -0
- package/dist/pipeline/worker.js +1639 -0
- package/dist/pipeline/worker_observer.d.ts +131 -0
- package/dist/pipeline/worker_observer.js +274 -0
- package/dist/pipeline/worker_ready_decorator.d.ts +45 -0
- package/dist/pipeline/worker_ready_decorator.js +76 -0
- package/dist/processors/aggregators/async_tool_messages.d.ts +146 -0
- package/dist/processors/aggregators/async_tool_messages.js +291 -0
- package/dist/processors/aggregators/dtmf_aggregator.d.ts +61 -0
- package/dist/processors/aggregators/dtmf_aggregator.js +144 -0
- package/dist/processors/aggregators/gated.d.ts +43 -0
- package/dist/processors/aggregators/gated.js +86 -0
- package/dist/processors/aggregators/gated_llm_context.d.ts +42 -0
- package/dist/processors/aggregators/gated_llm_context.js +86 -0
- package/dist/processors/aggregators/index.d.ts +2 -0
- package/dist/processors/aggregators/index.js +8 -0
- package/dist/processors/aggregators/llm_context.d.ts +370 -0
- package/dist/processors/aggregators/llm_context.js +580 -0
- package/dist/processors/aggregators/llm_context_summarizer.d.ts +219 -0
- package/dist/processors/aggregators/llm_context_summarizer.js +447 -0
- package/dist/processors/aggregators/llm_response.d.ts +37 -0
- package/dist/processors/aggregators/llm_response.js +71 -0
- package/dist/processors/aggregators/llm_response_universal.d.ts +966 -0
- package/dist/processors/aggregators/llm_response_universal.js +2394 -0
- package/dist/processors/aggregators/llm_text_processor.d.ts +53 -0
- package/dist/processors/aggregators/llm_text_processor.js +102 -0
- package/dist/processors/aggregators/sentence.d.ts +39 -0
- package/dist/processors/aggregators/sentence.js +69 -0
- package/dist/processors/async_generator.d.ts +42 -0
- package/dist/processors/async_generator.js +76 -0
- package/dist/processors/audio/audio_buffer_processor.d.ts +241 -0
- package/dist/processors/audio/audio_buffer_processor.js +565 -0
- package/dist/processors/audio/index.d.ts +2 -0
- package/dist/processors/audio/index.js +8 -0
- package/dist/processors/audio/vad_processor.d.ts +67 -0
- package/dist/processors/audio/vad_processor.js +103 -0
- package/dist/processors/consumer_processor.d.ts +49 -0
- package/dist/processors/consumer_processor.js +85 -0
- package/dist/processors/filters/frame_filter.d.ts +39 -0
- package/dist/processors/filters/frame_filter.js +52 -0
- package/dist/processors/filters/function_filter.d.ts +59 -0
- package/dist/processors/filters/function_filter.js +78 -0
- package/dist/processors/filters/identity_filter.d.ts +33 -0
- package/dist/processors/filters/identity_filter.js +37 -0
- package/dist/processors/filters/index.d.ts +2 -0
- package/dist/processors/filters/index.js +8 -0
- package/dist/processors/filters/null_filter.d.ts +34 -0
- package/dist/processors/filters/null_filter.js +47 -0
- package/dist/processors/filters/wake_notifier_filter.d.ts +48 -0
- package/dist/processors/filters/wake_notifier_filter.js +49 -0
- package/dist/processors/frame_processor.d.ts +360 -0
- package/dist/processors/frame_processor.js +932 -0
- package/dist/processors/frameworks/index.d.ts +2 -0
- package/dist/processors/frameworks/index.js +8 -0
- package/dist/processors/frameworks/rtvi/frames.d.ts +241 -0
- package/dist/processors/frameworks/rtvi/frames.js +259 -0
- package/dist/processors/frameworks/rtvi/index.d.ts +6 -0
- package/dist/processors/frameworks/rtvi/index.js +11 -0
- package/dist/processors/frameworks/rtvi/models.d.ts +1741 -0
- package/dist/processors/frameworks/rtvi/models.js +1807 -0
- package/dist/processors/frameworks/rtvi/observer.d.ts +340 -0
- package/dist/processors/frameworks/rtvi/observer.js +1113 -0
- package/dist/processors/frameworks/rtvi/processor.d.ts +182 -0
- package/dist/processors/frameworks/rtvi/processor.js +676 -0
- package/dist/processors/idle_frame_processor.d.ts +44 -0
- package/dist/processors/idle_frame_processor.js +86 -0
- package/dist/processors/index.d.ts +2 -0
- package/dist/processors/index.js +8 -0
- package/dist/processors/logger.d.ts +42 -0
- package/dist/processors/logger.js +87 -0
- package/dist/processors/metrics/frame_processor_metrics.d.ts +172 -0
- package/dist/processors/metrics/frame_processor_metrics.js +372 -0
- package/dist/processors/metrics/index.d.ts +2 -0
- package/dist/processors/metrics/index.js +8 -0
- package/dist/processors/producer_processor.d.ts +68 -0
- package/dist/processors/producer_processor.js +78 -0
- package/dist/processors/text_transformer.d.ts +30 -0
- package/dist/processors/text_transformer.js +48 -0
- package/dist/registry/index.d.ts +3 -0
- package/dist/registry/index.js +8 -0
- package/dist/registry/registry.d.ts +69 -0
- package/dist/registry/registry.js +149 -0
- package/dist/registry/types.d.ts +47 -0
- package/dist/registry/types.js +39 -0
- package/dist/serializers/base_serializer.d.ts +94 -0
- package/dist/serializers/base_serializer.js +82 -0
- package/dist/serializers/index.d.ts +2 -0
- package/dist/serializers/index.js +8 -0
- package/dist/services/ai_service.d.ts +145 -0
- package/dist/services/ai_service.js +262 -0
- package/dist/services/anthropic/index.d.ts +2 -0
- package/dist/services/anthropic/index.js +7 -0
- package/dist/services/assemblyai/index.d.ts +2 -0
- package/dist/services/assemblyai/index.js +7 -0
- package/dist/services/asyncai/index.d.ts +2 -0
- package/dist/services/asyncai/index.js +7 -0
- package/dist/services/aws/index.d.ts +2 -0
- package/dist/services/aws/index.js +7 -0
- package/dist/services/azure/index.d.ts +2 -0
- package/dist/services/azure/index.js +7 -0
- package/dist/services/baseten/index.d.ts +2 -0
- package/dist/services/baseten/index.js +7 -0
- package/dist/services/bland/index.d.ts +2 -0
- package/dist/services/bland/index.js +7 -0
- package/dist/services/camb/index.d.ts +2 -0
- package/dist/services/camb/index.js +7 -0
- package/dist/services/cartesia/index.d.ts +2 -0
- package/dist/services/cartesia/index.js +7 -0
- package/dist/services/cerebras/index.d.ts +2 -0
- package/dist/services/cerebras/index.js +7 -0
- package/dist/services/crusoe/index.d.ts +2 -0
- package/dist/services/crusoe/index.js +7 -0
- package/dist/services/deepgram/index.d.ts +2 -0
- package/dist/services/deepgram/index.js +7 -0
- package/dist/services/deepseek/index.d.ts +2 -0
- package/dist/services/deepseek/index.js +7 -0
- package/dist/services/elevenlabs/index.d.ts +2 -0
- package/dist/services/elevenlabs/index.js +7 -0
- package/dist/services/fal/index.d.ts +2 -0
- package/dist/services/fal/index.js +7 -0
- package/dist/services/fireworks/index.d.ts +2 -0
- package/dist/services/fireworks/index.js +7 -0
- package/dist/services/fish/index.d.ts +2 -0
- package/dist/services/fish/index.js +7 -0
- package/dist/services/funasr/index.d.ts +3 -0
- package/dist/services/funasr/index.js +8 -0
- package/dist/services/gladia/index.d.ts +2 -0
- package/dist/services/gladia/index.js +7 -0
- package/dist/services/google/index.d.ts +2 -0
- package/dist/services/google/index.js +7 -0
- package/dist/services/gradium/index.d.ts +2 -0
- package/dist/services/gradium/index.js +7 -0
- package/dist/services/grok/index.d.ts +2 -0
- package/dist/services/grok/index.js +7 -0
- package/dist/services/groq/index.d.ts +2 -0
- package/dist/services/groq/index.js +7 -0
- package/dist/services/heygen/index.d.ts +2 -0
- package/dist/services/heygen/index.js +7 -0
- package/dist/services/hume/index.d.ts +2 -0
- package/dist/services/hume/index.js +7 -0
- package/dist/services/image_service.d.ts +52 -0
- package/dist/services/image_service.js +60 -0
- package/dist/services/inception/index.d.ts +2 -0
- package/dist/services/inception/index.js +7 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +8 -0
- package/dist/services/inworld/index.d.ts +2 -0
- package/dist/services/inworld/index.js +7 -0
- package/dist/services/keenable/index.d.ts +2 -0
- package/dist/services/keenable/index.js +7 -0
- package/dist/services/kokoro/index.d.ts +2 -0
- package/dist/services/kokoro/index.js +7 -0
- package/dist/services/llm_service.d.ts +1106 -0
- package/dist/services/llm_service.js +2231 -0
- package/dist/services/mem0/index.d.ts +2 -0
- package/dist/services/mem0/index.js +7 -0
- package/dist/services/meta/index.d.ts +2 -0
- package/dist/services/meta/index.js +7 -0
- package/dist/services/minimax/index.d.ts +2 -0
- package/dist/services/minimax/index.js +7 -0
- package/dist/services/mistral/index.d.ts +2 -0
- package/dist/services/mistral/index.js +7 -0
- package/dist/services/moondream/index.d.ts +2 -0
- package/dist/services/moondream/index.js +7 -0
- package/dist/services/moonshine/index.d.ts +2 -0
- package/dist/services/moonshine/index.js +7 -0
- package/dist/services/nebius/index.d.ts +2 -0
- package/dist/services/nebius/index.js +7 -0
- package/dist/services/neuphonic/index.d.ts +2 -0
- package/dist/services/neuphonic/index.js +7 -0
- package/dist/services/novita/index.d.ts +2 -0
- package/dist/services/novita/index.js +7 -0
- package/dist/services/nvidia/index.d.ts +2 -0
- package/dist/services/nvidia/index.js +11 -0
- package/dist/services/ollama/index.d.ts +2 -0
- package/dist/services/ollama/index.js +7 -0
- package/dist/services/openai/index.d.ts +2 -0
- package/dist/services/openai/index.js +7 -0
- package/dist/services/openclaw/index.d.ts +14 -0
- package/dist/services/openclaw/index.js +19 -0
- package/dist/services/openrouter/index.d.ts +2 -0
- package/dist/services/openrouter/index.js +7 -0
- package/dist/services/perplexity/index.d.ts +2 -0
- package/dist/services/perplexity/index.js +7 -0
- package/dist/services/piper/index.d.ts +2 -0
- package/dist/services/piper/index.js +7 -0
- package/dist/services/pocket_tts/index.d.ts +2 -0
- package/dist/services/pocket_tts/index.js +7 -0
- package/dist/services/qwen/index.d.ts +2 -0
- package/dist/services/qwen/index.js +7 -0
- package/dist/services/resembleai/index.d.ts +2 -0
- package/dist/services/resembleai/index.js +7 -0
- package/dist/services/rime/index.d.ts +2 -0
- package/dist/services/rime/index.js +7 -0
- package/dist/services/sambanova/index.d.ts +2 -0
- package/dist/services/sambanova/index.js +7 -0
- package/dist/services/sarvam/index.d.ts +2 -0
- package/dist/services/sarvam/index.js +7 -0
- package/dist/services/settings.d.ts +356 -0
- package/dist/services/settings.js +437 -0
- package/dist/services/simli/index.d.ts +2 -0
- package/dist/services/simli/index.js +7 -0
- package/dist/services/smallest/index.d.ts +2 -0
- package/dist/services/smallest/index.js +7 -0
- package/dist/services/soniox/index.d.ts +2 -0
- package/dist/services/soniox/index.js +7 -0
- package/dist/services/speechify/index.d.ts +2 -0
- package/dist/services/speechify/index.js +7 -0
- package/dist/services/speechmatics/index.d.ts +2 -0
- package/dist/services/speechmatics/index.js +7 -0
- package/dist/services/stt_latency.d.ts +62 -0
- package/dist/services/stt_latency.js +71 -0
- package/dist/services/stt_service.d.ts +601 -0
- package/dist/services/stt_service.js +1044 -0
- package/dist/services/tavus/index.d.ts +2 -0
- package/dist/services/tavus/index.js +7 -0
- package/dist/services/together/index.d.ts +2 -0
- package/dist/services/together/index.js +7 -0
- package/dist/services/tts_service.d.ts +909 -0
- package/dist/services/tts_service.js +2018 -0
- package/dist/services/ultravox/index.d.ts +2 -0
- package/dist/services/ultravox/index.js +9 -0
- package/dist/services/vision_service.d.ts +56 -0
- package/dist/services/vision_service.js +62 -0
- package/dist/services/websocket_service.d.ts +213 -0
- package/dist/services/websocket_service.js +654 -0
- package/dist/services/whisper/index.d.ts +2 -0
- package/dist/services/whisper/index.js +9 -0
- package/dist/services/xai/index.d.ts +2 -0
- package/dist/services/xai/index.js +9 -0
- package/dist/services/xtts/index.d.ts +2 -0
- package/dist/services/xtts/index.js +9 -0
- package/dist/tests/index.d.ts +2 -0
- package/dist/tests/index.js +8 -0
- package/dist/tests/utils.d.ts +123 -0
- package/dist/tests/utils.js +212 -0
- package/dist/transcriptions/index.d.ts +2 -0
- package/dist/transcriptions/index.js +8 -0
- package/dist/transcriptions/language.d.ts +376 -0
- package/dist/transcriptions/language.js +543 -0
- package/dist/transports/base_input.d.ts +149 -0
- package/dist/transports/base_input.js +338 -0
- package/dist/transports/base_output.d.ts +432 -0
- package/dist/transports/base_output.js +1231 -0
- package/dist/transports/base_transport.d.ts +223 -0
- package/dist/transports/base_transport.js +167 -0
- package/dist/transports/daily/index.d.ts +2 -0
- package/dist/transports/daily/index.js +9 -0
- package/dist/transports/heygen/index.d.ts +2 -0
- package/dist/transports/heygen/index.js +9 -0
- package/dist/transports/index.d.ts +2 -0
- package/dist/transports/index.js +8 -0
- package/dist/transports/lemonslice/index.d.ts +2 -0
- package/dist/transports/lemonslice/index.js +9 -0
- package/dist/transports/livekit/index.d.ts +2 -0
- package/dist/transports/livekit/index.js +9 -0
- package/dist/transports/local/index.d.ts +2 -0
- package/dist/transports/local/index.js +9 -0
- package/dist/transports/moq/index.d.ts +2 -0
- package/dist/transports/moq/index.js +9 -0
- package/dist/transports/smallwebrtc/index.d.ts +2 -0
- package/dist/transports/smallwebrtc/index.js +9 -0
- package/dist/transports/tavus/index.d.ts +2 -0
- package/dist/transports/tavus/index.js +9 -0
- package/dist/transports/video_in_sampler.d.ts +157 -0
- package/dist/transports/video_in_sampler.js +258 -0
- package/dist/transports/vonage/index.d.ts +2 -0
- package/dist/transports/vonage/index.js +9 -0
- package/dist/transports/websocket/index.d.ts +2 -0
- package/dist/transports/websocket/index.js +9 -0
- package/dist/transports/whatsapp/index.d.ts +2 -0
- package/dist/transports/whatsapp/index.js +9 -0
- package/dist/turns/eager_end_of_turn_mixin.d.ts +70 -0
- package/dist/turns/eager_end_of_turn_mixin.js +122 -0
- package/dist/turns/empty_user_turn.d.ts +55 -0
- package/dist/turns/empty_user_turn.js +53 -0
- package/dist/turns/index.d.ts +2 -0
- package/dist/turns/index.js +8 -0
- package/dist/turns/speculation_gate.d.ts +169 -0
- package/dist/turns/speculation_gate.js +294 -0
- package/dist/turns/types.d.ts +33 -0
- package/dist/turns/types.js +35 -0
- package/dist/turns/user_idle_controller.d.ts +94 -0
- package/dist/turns/user_idle_controller.js +187 -0
- package/dist/turns/user_mute/always_user_mute_strategy.d.ts +15 -0
- package/dist/turns/user_mute/always_user_mute_strategy.js +29 -0
- package/dist/turns/user_mute/base_user_mute_strategy.d.ts +39 -0
- package/dist/turns/user_mute/base_user_mute_strategy.js +45 -0
- package/dist/turns/user_mute/first_speech_user_mute_strategy.d.ts +28 -0
- package/dist/turns/user_mute/first_speech_user_mute_strategy.js +52 -0
- package/dist/turns/user_mute/function_call_user_mute_strategy.d.ts +25 -0
- package/dist/turns/user_mute/function_call_user_mute_strategy.js +50 -0
- package/dist/turns/user_mute/index.d.ts +6 -0
- package/dist/turns/user_mute/index.js +11 -0
- package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.d.ts +43 -0
- package/dist/turns/user_mute/mute_until_first_bot_complete_user_mute_strategy.js +76 -0
- package/dist/turns/user_start/base_user_turn_start_strategy.d.ts +135 -0
- package/dist/turns/user_start/base_user_turn_start_strategy.js +134 -0
- package/dist/turns/user_start/external_user_turn_start_strategy.d.ts +45 -0
- package/dist/turns/user_start/external_user_turn_start_strategy.js +64 -0
- package/dist/turns/user_start/index.d.ts +8 -0
- package/dist/turns/user_start/index.js +16 -0
- package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.d.ts +133 -0
- package/dist/turns/user_start/krisp_viva_ip_user_turn_start_strategy.js +243 -0
- package/dist/turns/user_start/min_words_user_turn_start_strategy.d.ts +60 -0
- package/dist/turns/user_start/min_words_user_turn_start_strategy.js +102 -0
- package/dist/turns/user_start/transcription_user_turn_start_strategy.d.ts +29 -0
- package/dist/turns/user_start/transcription_user_turn_start_strategy.js +43 -0
- package/dist/turns/user_start/vad_user_turn_start_strategy.d.ts +20 -0
- package/dist/turns/user_start/vad_user_turn_start_strategy.js +31 -0
- package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.d.ts +141 -0
- package/dist/turns/user_start/wake_phrase_user_turn_start_strategy.js +238 -0
- package/dist/turns/user_stop/base_user_turn_stop_strategy.d.ts +174 -0
- package/dist/turns/user_stop/base_user_turn_stop_strategy.js +170 -0
- package/dist/turns/user_stop/deferred_user_turn_stop_strategy.d.ts +81 -0
- package/dist/turns/user_stop/deferred_user_turn_stop_strategy.js +107 -0
- package/dist/turns/user_stop/eager_match_policy.d.ts +36 -0
- package/dist/turns/user_stop/eager_match_policy.js +50 -0
- package/dist/turns/user_stop/eager_user_turn_stop_strategy.d.ts +84 -0
- package/dist/turns/user_stop/eager_user_turn_stop_strategy.js +154 -0
- package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.d.ts +45 -0
- package/dist/turns/user_stop/external_user_turn_completion_stop_strategy.js +55 -0
- package/dist/turns/user_stop/external_user_turn_stop_strategy.d.ts +115 -0
- package/dist/turns/user_stop/external_user_turn_stop_strategy.js +205 -0
- package/dist/turns/user_stop/index.d.ts +10 -0
- package/dist/turns/user_stop/index.js +15 -0
- package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.d.ts +44 -0
- package/dist/turns/user_stop/llm_turn_completion_user_turn_stop_strategy.js +59 -0
- package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.d.ts +140 -0
- package/dist/turns/user_stop/speech_timeout_user_turn_stop_strategy.js +303 -0
- package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.d.ts +135 -0
- package/dist/turns/user_stop/turn_analyzer_user_turn_stop_strategy.js +332 -0
- package/dist/turns/user_turn_completion_mixin.d.ts +147 -0
- package/dist/turns/user_turn_completion_mixin.js +591 -0
- package/dist/turns/user_turn_controller.d.ts +134 -0
- package/dist/turns/user_turn_controller.js +335 -0
- package/dist/turns/user_turn_processor.d.ts +87 -0
- package/dist/turns/user_turn_processor.js +180 -0
- package/dist/turns/user_turn_strategies.d.ts +187 -0
- package/dist/turns/user_turn_strategies.js +222 -0
- package/dist/utils/async_tool_cancellation.d.ts +35 -0
- package/dist/utils/async_tool_cancellation.js +78 -0
- package/dist/utils/asyncio/index.d.ts +2 -0
- package/dist/utils/asyncio/index.js +7 -0
- package/dist/utils/asyncio/task_manager.d.ts +49 -0
- package/dist/utils/asyncio/task_manager.js +105 -0
- package/dist/utils/base_object.d.ts +76 -0
- package/dist/utils/base_object.js +154 -0
- package/dist/utils/context/aggregated_frame_sequencer.d.ts +491 -0
- package/dist/utils/context/aggregated_frame_sequencer.js +803 -0
- package/dist/utils/context/audio_context_manager.d.ts +131 -0
- package/dist/utils/context/audio_context_manager.js +233 -0
- package/dist/utils/context/index.d.ts +2 -0
- package/dist/utils/context/index.js +7 -0
- package/dist/utils/context/llm_context_summarization.d.ts +258 -0
- package/dist/utils/context/llm_context_summarization.js +511 -0
- package/dist/utils/context/text_segment_map.d.ts +611 -0
- package/dist/utils/context/text_segment_map.js +1132 -0
- package/dist/utils/context/word_completion_tracker.d.ts +273 -0
- package/dist/utils/context/word_completion_tracker.js +441 -0
- package/dist/utils/context/word_timestamp_tracker.d.ts +72 -0
- package/dist/utils/context/word_timestamp_tracker.js +98 -0
- package/dist/utils/deprecation.d.ts +28 -0
- package/dist/utils/deprecation.js +75 -0
- package/dist/utils/env.d.ts +38 -0
- package/dist/utils/env.js +62 -0
- package/dist/utils/errors.d.ts +75 -0
- package/dist/utils/errors.js +202 -0
- package/dist/utils/file_resolver.d.ts +126 -0
- package/dist/utils/file_resolver.js +314 -0
- package/dist/utils/file_storage.d.ts +99 -0
- package/dist/utils/file_storage.js +100 -0
- package/dist/utils/frame_queue.d.ts +36 -0
- package/dist/utils/frame_queue.js +66 -0
- package/dist/utils/http.d.ts +39 -0
- package/dist/utils/http.js +53 -0
- package/dist/utils/image.d.ts +15 -0
- package/dist/utils/image.js +30 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +8 -0
- package/dist/utils/log_config.d.ts +34 -0
- package/dist/utils/log_config.js +76 -0
- package/dist/utils/logger.d.ts +40 -0
- package/dist/utils/logger.js +91 -0
- package/dist/utils/mixin.d.ts +14 -0
- package/dist/utils/mixin.js +63 -0
- package/dist/utils/network.d.ts +73 -0
- package/dist/utils/network.js +90 -0
- package/dist/utils/security/allowed_origins.d.ts +16 -0
- package/dist/utils/security/allowed_origins.js +34 -0
- package/dist/utils/security/index.d.ts +2 -0
- package/dist/utils/security/index.js +7 -0
- package/dist/utils/security/redaction.d.ts +27 -0
- package/dist/utils/security/redaction.js +123 -0
- package/dist/utils/security/ssrf.d.ts +79 -0
- package/dist/utils/security/ssrf.js +327 -0
- package/dist/utils/shared.d.ts +35 -0
- package/dist/utils/shared.js +136 -0
- package/dist/utils/startup.d.ts +17 -0
- package/dist/utils/startup.js +130 -0
- package/dist/utils/string.d.ts +116 -0
- package/dist/utils/string.js +460 -0
- package/dist/utils/sync/base_notifier.d.ts +25 -0
- package/dist/utils/sync/base_notifier.js +16 -0
- package/dist/utils/sync/event_notifier.d.ts +38 -0
- package/dist/utils/sync/event_notifier.js +51 -0
- package/dist/utils/sync/index.d.ts +2 -0
- package/dist/utils/sync/index.js +7 -0
- package/dist/utils/text/alnum_utils.d.ts +109 -0
- package/dist/utils/text/alnum_utils.js +262 -0
- package/dist/utils/text/base_text_aggregator.d.ts +146 -0
- package/dist/utils/text/base_text_aggregator.js +102 -0
- package/dist/utils/text/base_text_filter.d.ts +54 -0
- package/dist/utils/text/base_text_filter.js +50 -0
- package/dist/utils/text/index.d.ts +2 -0
- package/dist/utils/text/index.js +7 -0
- package/dist/utils/text/markdown_text_filter.d.ts +147 -0
- package/dist/utils/text/markdown_text_filter.js +522 -0
- package/dist/utils/text/markup_utils.d.ts +54 -0
- package/dist/utils/text/markup_utils.js +156 -0
- package/dist/utils/text/pattern_pair_aggregator.d.ts +251 -0
- package/dist/utils/text/pattern_pair_aggregator.js +478 -0
- package/dist/utils/text/phonemes.d.ts +60 -0
- package/dist/utils/text/phonemes.js +172 -0
- package/dist/utils/text/simple_text_aggregator.d.ts +135 -0
- package/dist/utils/text/simple_text_aggregator.js +254 -0
- package/dist/utils/text/skip_tags_aggregator.d.ts +85 -0
- package/dist/utils/text/skip_tags_aggregator.js +147 -0
- package/dist/utils/text/transforms/pronunciations.d.ts +65 -0
- package/dist/utils/text/transforms/pronunciations.js +111 -0
- package/dist/utils/text/word_timestamp_utils.d.ts +26 -0
- package/dist/utils/text/word_timestamp_utils.js +52 -0
- package/dist/utils/time.d.ts +13 -0
- package/dist/utils/time.js +31 -0
- package/dist/utils/tracing/index.d.ts +3 -0
- package/dist/utils/tracing/index.js +8 -0
- package/dist/utils/tracing/service_attributes.d.ts +198 -0
- package/dist/utils/tracing/service_attributes.js +434 -0
- package/dist/utils/tracing/service_decorators.d.ts +214 -0
- package/dist/utils/tracing/service_decorators.js +1662 -0
- package/dist/utils/tracing/setup.d.ts +95 -0
- package/dist/utils/tracing/setup.js +110 -0
- package/dist/utils/tracing/tracing_context.d.ts +55 -0
- package/dist/utils/tracing/tracing_context.js +97 -0
- package/dist/utils/tracing/turn_trace_observer.d.ts +90 -0
- package/dist/utils/tracing/turn_trace_observer.js +219 -0
- package/dist/utils/types.d.ts +80 -0
- package/dist/utils/types.js +108 -0
- package/dist/utils/utils.d.ts +5 -0
- package/dist/utils/utils.js +22 -0
- package/dist/utils/yaml.d.ts +64 -0
- package/dist/utils/yaml.js +41 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +7 -0
- package/dist/workers/base_worker.d.ts +772 -0
- package/dist/workers/base_worker.js +1298 -0
- package/dist/workers/index.d.ts +2 -0
- package/dist/workers/index.js +8 -0
- package/dist/workers/llm/backend_llm_worker.d.ts +552 -0
- package/dist/workers/llm/backend_llm_worker.js +1055 -0
- package/dist/workers/llm/index.d.ts +6 -0
- package/dist/workers/llm/index.js +11 -0
- package/dist/workers/llm/llm_context_worker.d.ts +66 -0
- package/dist/workers/llm/llm_context_worker.js +72 -0
- package/dist/workers/llm/llm_worker.d.ts +180 -0
- package/dist/workers/llm/llm_worker.js +323 -0
- package/dist/workers/llm/tool_decorator.d.ts +68 -0
- package/dist/workers/llm/tool_decorator.js +60 -0
- package/dist/workers/runner.d.ts +268 -0
- package/dist/workers/runner.js +489 -0
- package/dist/workers/ui/index.d.ts +22 -0
- package/dist/workers/ui/index.js +27 -0
- package/dist/workers/ui/ui_event_decorator.d.ts +43 -0
- package/dist/workers/ui/ui_event_decorator.js +75 -0
- package/dist/workers/ui/ui_job_context.d.ts +12 -0
- package/dist/workers/ui/ui_job_context.js +17 -0
- package/dist/workers/ui/ui_prompts.d.ts +21 -0
- package/dist/workers/ui/ui_prompts.js +41 -0
- package/dist/workers/ui/ui_tools.d.ts +32 -0
- package/dist/workers/ui/ui_tools.js +112 -0
- package/dist/workers/ui/ui_worker.d.ts +571 -0
- package/dist/workers/ui/ui_worker.js +1156 -0
- package/package.json +46 -3
- package/README.md +0 -5
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base classes for Text-to-speech services.
|
|
3
|
+
*
|
|
4
|
+
* Porting notes: the deprecated `aggregateSentences`, `pauseWatchdogTimeoutS`
|
|
5
|
+
* and `skipAggregatorTypes` constructor options, the deprecated
|
|
6
|
+
* `aggregationType` argument of `addTextTransformer()` /
|
|
7
|
+
* `removeTextTransformer()`, `setModel()` / `setVoice()`, the legacy
|
|
8
|
+
* `TTSUpdateSettingsFrame(settings={...})` path and the deprecated
|
|
9
|
+
* `WordTTSService`, `WebsocketWordTTSService`, `InterruptibleWordTTSService`,
|
|
10
|
+
* `AudioContextTTSService` and `AudioContextWordTTSService` classes are not
|
|
11
|
+
* ported.
|
|
12
|
+
*/
|
|
13
|
+
import { type Task } from "@pipedog/asyncio";
|
|
14
|
+
import type { BaseAudioResampler } from "../audio/resamplers/base_audio_resampler.ts";
|
|
15
|
+
import { AggregatedTextFrame, type CancelFrame, EndFrame, ErrorFrame, Frame, InterruptionFrame, LLMFullResponseEndFrame, LLMFullResponseStartFrame, LLMTextFrame, type StartFrame, TextFrame, TextType, TTSSpeakFrame, TTSStoppedFrame, TTSUpdateSettingsFrame } from "../frames/frames.ts";
|
|
16
|
+
import { FrameDirection, type FrameProcessorSetup } from "../processors/frame_processor.ts";
|
|
17
|
+
import { type Language } from "../transcriptions/language.ts";
|
|
18
|
+
import { AggregatedFrameSequencer } from "../utils/context/aggregated_frame_sequencer.ts";
|
|
19
|
+
import { AudioContextManager } from "../utils/context/audio_context_manager.ts";
|
|
20
|
+
import { WordTimestamp, WordTimestampTracker } from "../utils/context/word_timestamp_tracker.ts";
|
|
21
|
+
import type { Aggregation } from "../utils/text/base_text_aggregator.ts";
|
|
22
|
+
import type { BaseTextFilter } from "../utils/text/base_text_filter.ts";
|
|
23
|
+
import { SimpleTextAggregator } from "../utils/text/simple_text_aggregator.ts";
|
|
24
|
+
import { PronunciationTransform } from "../utils/text/transforms/pronunciations.ts";
|
|
25
|
+
import { AIService, type AIServiceOptions } from "./ai_service.ts";
|
|
26
|
+
import { TTSSettings } from "./settings.ts";
|
|
27
|
+
import { WebsocketService, type WebsocketServiceOptions } from "./websocket_service.ts";
|
|
28
|
+
/**
|
|
29
|
+
* Controls how incoming text is aggregated before TTS synthesis.
|
|
30
|
+
*
|
|
31
|
+
* - SENTENCE: Buffer text until sentence boundaries are detected before
|
|
32
|
+
* synthesis. Produces more natural speech but adds latency (~200-300ms per
|
|
33
|
+
* sentence).
|
|
34
|
+
* - TOKEN: Stream text tokens directly to TTS as they arrive. Reduces latency
|
|
35
|
+
* but may affect speech quality depending on the TTS provider.
|
|
36
|
+
*/
|
|
37
|
+
export declare const TextAggregationMode: {
|
|
38
|
+
readonly SENTENCE: "sentence";
|
|
39
|
+
readonly TOKEN: "token";
|
|
40
|
+
};
|
|
41
|
+
export type TextAggregationMode = (typeof TextAggregationMode)[keyof typeof TextAggregationMode];
|
|
42
|
+
/**
|
|
43
|
+
* A text transform: takes the aggregated text and its type, and returns the
|
|
44
|
+
* transformed text.
|
|
45
|
+
*/
|
|
46
|
+
export type TextTransformFunction = (text: string, textType: TextType | string) => Promise<string>;
|
|
47
|
+
export interface TTSContextOptions {
|
|
48
|
+
/**
|
|
49
|
+
* Whether this TTS output should be appended to the conversation context
|
|
50
|
+
* after it is spoken.
|
|
51
|
+
*/
|
|
52
|
+
appendToContext?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to push an `LLMAssistantPushAggregationFrame` after the TTS has
|
|
55
|
+
* finished speaking, forcing the assistant aggregator to commit its current
|
|
56
|
+
* text buffer to the conversation context.
|
|
57
|
+
*/
|
|
58
|
+
pushAssistantAggregation?: boolean;
|
|
59
|
+
/** Whether an interruption may discard this synthesis. */
|
|
60
|
+
interruptible?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Context information for a TTS request.
|
|
64
|
+
*
|
|
65
|
+
* - `appendToContext`: Whether this TTS output should be appended to the
|
|
66
|
+
* conversation context after it is spoken.
|
|
67
|
+
* - `pushAssistantAggregation`: Whether to push an
|
|
68
|
+
* `LLMAssistantPushAggregationFrame` after the TTS has finished speaking,
|
|
69
|
+
* forcing the assistant aggregator to commit its current text buffer to the
|
|
70
|
+
* conversation context.
|
|
71
|
+
* - `interruptible`: Whether an interruption may discard this synthesis.
|
|
72
|
+
*/
|
|
73
|
+
export declare class TTSContext {
|
|
74
|
+
appendToContext: boolean;
|
|
75
|
+
pushAssistantAggregation: boolean;
|
|
76
|
+
interruptible: boolean;
|
|
77
|
+
constructor(options?: TTSContextOptions);
|
|
78
|
+
}
|
|
79
|
+
/** Internal: what has happened so far while an audio context plays. */
|
|
80
|
+
export declare class _AudioContextPlayback {
|
|
81
|
+
receivedAudio: boolean;
|
|
82
|
+
stopFrameDue: boolean;
|
|
83
|
+
}
|
|
84
|
+
/** An item queued in an audio context. */
|
|
85
|
+
export type AudioContextItem = Frame | WordTimestamp;
|
|
86
|
+
export interface TTSServiceOptions extends AIServiceOptions {
|
|
87
|
+
/**
|
|
88
|
+
* How to aggregate incoming text before synthesis.
|
|
89
|
+
* `TextAggregationMode.SENTENCE` (default) buffers until sentence
|
|
90
|
+
* boundaries, `TextAggregationMode.TOKEN` streams tokens directly for lower
|
|
91
|
+
* latency.
|
|
92
|
+
*/
|
|
93
|
+
textAggregationMode?: TextAggregationMode | null;
|
|
94
|
+
/** Whether to push TextFrames and LLMFullResponseEndFrames. */
|
|
95
|
+
pushTextFrames?: boolean;
|
|
96
|
+
/** Whether to automatically push TTSStoppedFrames. */
|
|
97
|
+
pushStopFrames?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Whether to automatically create audio contexts and push TTSStartedFrames.
|
|
100
|
+
* When true, the base class handles `createAudioContext` and yields
|
|
101
|
+
* `TTSStartedFrame` before each synthesis call, so `runTts`
|
|
102
|
+
* implementations do not need to.
|
|
103
|
+
*/
|
|
104
|
+
pushStartFrame?: boolean;
|
|
105
|
+
/** Idle time before pushing TTSStoppedFrame when pushStopFrames is true. */
|
|
106
|
+
stopFrameTimeoutS?: number;
|
|
107
|
+
/** Whether to push silence audio after TTSStoppedFrame. */
|
|
108
|
+
pushSilenceAfterStop?: boolean;
|
|
109
|
+
/** Duration of silence to push when pushSilenceAfterStop is true. */
|
|
110
|
+
silenceTimeS?: number;
|
|
111
|
+
/**
|
|
112
|
+
* Whether to hold incoming frames after a turn until its audio contexts
|
|
113
|
+
* end. Needed by services whose audio doesn't carry its request's context
|
|
114
|
+
* ID.
|
|
115
|
+
*/
|
|
116
|
+
pauseFrameProcessing?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* How many consecutive TTS contexts may complete without producing any
|
|
119
|
+
* audio before the service is reported unable to do its job. Catches a
|
|
120
|
+
* provider that accepts requests and stays silent — an unknown voice ID,
|
|
121
|
+
* say — which no error ever surfaces. Every silent context reports an error
|
|
122
|
+
* the service can carry on from, whatever the limit is; on reaching the
|
|
123
|
+
* limit the service reports a permanent error instead, stops being given
|
|
124
|
+
* work, and the pipeline worker applies its `ProcessorUnusablePolicy`. Set
|
|
125
|
+
* to 0 to report silent contexts without ever writing the service off.
|
|
126
|
+
*/
|
|
127
|
+
maxConsecutiveZeroAudioContexts?: number;
|
|
128
|
+
/**
|
|
129
|
+
* Whether to append a trailing space to text before sending to TTS. This
|
|
130
|
+
* helps prevent some TTS services from vocalizing trailing punctuation
|
|
131
|
+
* (e.g., "dot"). Only applied in sentence aggregation mode; when streaming
|
|
132
|
+
* tokens, the incoming text's own whitespace is preserved.
|
|
133
|
+
*/
|
|
134
|
+
appendTrailingSpace?: boolean;
|
|
135
|
+
/** Output sample rate for generated audio. */
|
|
136
|
+
sampleRate?: number | null;
|
|
137
|
+
/** List of text types that should not be spoken. */
|
|
138
|
+
skipTextTypes?: string[] | null;
|
|
139
|
+
/**
|
|
140
|
+
* A list of callables to transform text just before sending it to TTS.
|
|
141
|
+
* Each callable takes the aggregated text and its type, and returns the
|
|
142
|
+
* transformed text. To register, provide a list of tuples of
|
|
143
|
+
* `[textType | "*", transformFunction]`.
|
|
144
|
+
*/
|
|
145
|
+
textTransforms?: [TextType | string, TextTransformFunction][] | null;
|
|
146
|
+
/** Sequence of text filters to apply after aggregation. */
|
|
147
|
+
textFilters?: readonly BaseTextFilter[] | null;
|
|
148
|
+
/** Destination for generated audio frames. */
|
|
149
|
+
transportDestination?: string | null;
|
|
150
|
+
/** The runtime-updatable settings for the TTS service. */
|
|
151
|
+
settings?: TTSSettings | null;
|
|
152
|
+
/** Whether the service should reuse context IDs within the same turn. */
|
|
153
|
+
reuseContextIdWithinTurn?: boolean;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Base class for text-to-speech services.
|
|
157
|
+
*
|
|
158
|
+
* Provides common functionality for TTS services including text aggregation,
|
|
159
|
+
* filtering, audio generation, and frame management. Supports configurable
|
|
160
|
+
* sentence aggregation, silence insertion, and frame processing control.
|
|
161
|
+
*
|
|
162
|
+
* Event handlers:
|
|
163
|
+
*
|
|
164
|
+
* - on_connected: Called when connected to the TTS service.
|
|
165
|
+
* - on_disconnected: Called when disconnected from the TTS service.
|
|
166
|
+
* - on_connection_error: Called when a connection to the TTS service error occurs.
|
|
167
|
+
* - on_tts_request: Called before a TTS request is made, with the context ID and text.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* tts.eventHandler("on_connected", async (tts: TTSService) => {
|
|
171
|
+
* logger.debug("TTS connected");
|
|
172
|
+
* });
|
|
173
|
+
* tts.eventHandler("on_disconnected", async (tts: TTSService) => {
|
|
174
|
+
* logger.debug("TTS disconnected");
|
|
175
|
+
* });
|
|
176
|
+
* tts.eventHandler("on_connection_error", async (tts: TTSService, error: string) => {
|
|
177
|
+
* logger.error(`TTS connection error: ${error}`);
|
|
178
|
+
* });
|
|
179
|
+
* tts.eventHandler("on_tts_request", async (tts: TTSService, contextId: string, text: string) => {
|
|
180
|
+
* logger.debug(`TTS request: ${contextId} - ${text}`);
|
|
181
|
+
* });
|
|
182
|
+
*/
|
|
183
|
+
export declare abstract class TTSService extends AIService {
|
|
184
|
+
protected _settings: TTSSettings;
|
|
185
|
+
protected _textAggregationMode: TextAggregationMode;
|
|
186
|
+
protected _pushTextFrames: boolean;
|
|
187
|
+
protected _pushStopFrames: boolean;
|
|
188
|
+
protected _pushStartFrame: boolean;
|
|
189
|
+
protected _stopFrameTimeoutS: number;
|
|
190
|
+
protected _pushSilenceAfterStop: boolean;
|
|
191
|
+
protected _silenceTimeS: number;
|
|
192
|
+
protected _pauseFrameProcessing: boolean;
|
|
193
|
+
protected _maxConsecutiveZeroAudioContexts: number;
|
|
194
|
+
protected _consecutiveZeroAudioContexts: number;
|
|
195
|
+
protected _appendTrailingSpace: boolean;
|
|
196
|
+
protected _initSampleRate: number | null;
|
|
197
|
+
protected _sampleRate: number;
|
|
198
|
+
protected _textAggregator: SimpleTextAggregator;
|
|
199
|
+
protected _skippedTextAggregator: SimpleTextAggregator;
|
|
200
|
+
protected _skipTextTypes: string[];
|
|
201
|
+
protected _textTransforms: [TextType | string, TextTransformFunction][];
|
|
202
|
+
protected _skippingPronunciations: boolean;
|
|
203
|
+
protected _textFilters: readonly BaseTextFilter[];
|
|
204
|
+
protected _transportDestination: string | null;
|
|
205
|
+
protected _aggregatedFrameSequencer: AggregatedFrameSequencer;
|
|
206
|
+
protected _resampler: BaseAudioResampler;
|
|
207
|
+
protected _ttsContexts: Map<string, TTSContext>;
|
|
208
|
+
protected _streamedText: string;
|
|
209
|
+
protected _sentNonWhitespaceInContext: boolean;
|
|
210
|
+
protected _textAggregationMetricsStarted: boolean;
|
|
211
|
+
protected _wordTimestampTracker: WordTimestampTracker;
|
|
212
|
+
protected _reuseContextIdWithinTurn: boolean;
|
|
213
|
+
protected _turnContextId: string | null;
|
|
214
|
+
protected _audioContextManager: AudioContextManager;
|
|
215
|
+
protected _audioContextTask: Task<unknown> | null;
|
|
216
|
+
protected _isYieldingFramesSynchronously: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* Initialize the TTS service.
|
|
219
|
+
*
|
|
220
|
+
* @param options See `TTSServiceOptions`. Other options are passed to the
|
|
221
|
+
* parent AIService.
|
|
222
|
+
*/
|
|
223
|
+
constructor(options?: TTSServiceOptions);
|
|
224
|
+
/** The current sample rate for audio output, in Hz. */
|
|
225
|
+
get sampleRate(): number;
|
|
226
|
+
/**
|
|
227
|
+
* The recommended chunk size for audio streaming, in bytes.
|
|
228
|
+
*
|
|
229
|
+
* This property indicates how much audio we download (from TTS services
|
|
230
|
+
* that require chunking) before we start pushing the first audio frame.
|
|
231
|
+
* This will make sure we download the rest of the audio while audio is
|
|
232
|
+
* being played without causing audio glitches (specially at the
|
|
233
|
+
* beginning). Of course, this will also depend on how fast the TTS service
|
|
234
|
+
* generates bytes.
|
|
235
|
+
*/
|
|
236
|
+
get chunkSize(): number;
|
|
237
|
+
/** Current sentence tokenizer language, derived from TTS settings. */
|
|
238
|
+
get textAggregationLanguage(): string;
|
|
239
|
+
/**
|
|
240
|
+
* Whether this service has a meaningful processing-time metric.
|
|
241
|
+
*
|
|
242
|
+
* Processing time is measured around `runTts()`, so it only means something
|
|
243
|
+
* when synthesis finishes before `runTts` returns. Services that hand the
|
|
244
|
+
* text off and receive audio elsewhere — anything holding a persistent
|
|
245
|
+
* connection with its own receive task — return false, since the
|
|
246
|
+
* measurement would cover the send and nothing else. TTFB and TTFA carry
|
|
247
|
+
* the latency for those.
|
|
248
|
+
*/
|
|
249
|
+
get supportsProcessingMetrics(): boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Record TTS usage metrics.
|
|
252
|
+
*
|
|
253
|
+
* When streaming tokens, usage metrics are aggregated and reported at flush
|
|
254
|
+
* time instead of per token, so individual calls are skipped.
|
|
255
|
+
*
|
|
256
|
+
* @param text The text being processed by TTS.
|
|
257
|
+
*/
|
|
258
|
+
startTtsUsageMetrics(text: string): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Start text aggregation metrics if not already started.
|
|
261
|
+
*
|
|
262
|
+
* Only starts the metric once per LLM response. Skipped when streaming
|
|
263
|
+
* tokens since per-token aggregation time is not meaningful.
|
|
264
|
+
*/
|
|
265
|
+
startTextAggregationMetrics(): Promise<void>;
|
|
266
|
+
/** Stop text aggregation metrics and reset the started flag. */
|
|
267
|
+
stopTextAggregationMetrics(): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Set up the service.
|
|
270
|
+
*
|
|
271
|
+
* @param setup Configuration object containing setup parameters.
|
|
272
|
+
*/
|
|
273
|
+
setup(setup: FrameProcessorSetup): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Start the TTS service.
|
|
276
|
+
*
|
|
277
|
+
* @param frame The start frame containing initialization parameters.
|
|
278
|
+
*/
|
|
279
|
+
start(frame: StartFrame): Promise<void>;
|
|
280
|
+
/**
|
|
281
|
+
* Stop the TTS service.
|
|
282
|
+
*
|
|
283
|
+
* @param frame The end frame.
|
|
284
|
+
*/
|
|
285
|
+
stop(frame: EndFrame): Promise<void>;
|
|
286
|
+
/**
|
|
287
|
+
* Cancel the TTS service.
|
|
288
|
+
*
|
|
289
|
+
* @param frame The cancel frame.
|
|
290
|
+
*/
|
|
291
|
+
cancel(frame: CancelFrame): Promise<void>;
|
|
292
|
+
/** Release TTS resources at teardown. */
|
|
293
|
+
cleanup(): Promise<void>;
|
|
294
|
+
/**
|
|
295
|
+
* Set whether this service can be given work.
|
|
296
|
+
*
|
|
297
|
+
* @param isUsable Whether the service can be given work.
|
|
298
|
+
*/
|
|
299
|
+
setUsable(isUsable: boolean): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Transform text of a specific type.
|
|
302
|
+
*
|
|
303
|
+
* @param transformFunction The function to apply for transformation. This
|
|
304
|
+
* function should take the text and its type as input and return the
|
|
305
|
+
* transformed text, e.g.
|
|
306
|
+
* `async function myTransform(text: string, textType: string): Promise<string>`.
|
|
307
|
+
* @param textType The type of text to transform. This value defaults to
|
|
308
|
+
* "*" indicating the function should handle all text before sending to
|
|
309
|
+
* TTS.
|
|
310
|
+
*/
|
|
311
|
+
addTextTransformer(transformFunction: TextTransformFunction, textType?: TextType | string): void;
|
|
312
|
+
/**
|
|
313
|
+
* Remove a text transformer for a specific text type.
|
|
314
|
+
*
|
|
315
|
+
* @param transformFunction The function to remove.
|
|
316
|
+
* @param textType The type of text to remove the transformer for.
|
|
317
|
+
*/
|
|
318
|
+
removeTextTransformer(transformFunction: TextTransformFunction, textType?: TextType | string): void;
|
|
319
|
+
/**
|
|
320
|
+
* Render a word's pronunciation in this service's markup.
|
|
321
|
+
*
|
|
322
|
+
* Services that support pronunciation hints override this. The base
|
|
323
|
+
* implementation supports none.
|
|
324
|
+
*
|
|
325
|
+
* @param word The word as it appears in the text.
|
|
326
|
+
* @param ipa How to pronounce it, in IPA.
|
|
327
|
+
* @returns The text to send in place of `word`, or null when this service
|
|
328
|
+
* cannot use the pronunciation.
|
|
329
|
+
*/
|
|
330
|
+
static formatPronunciation(_word: string, _ipa: string): string | null;
|
|
331
|
+
/**
|
|
332
|
+
* Whether this service reads pronunciation markup with its current settings.
|
|
333
|
+
*
|
|
334
|
+
* Pronunciation transforms are skipped while this is false, so their words
|
|
335
|
+
* are spoken as written. Services whose markup depends on the model or on a
|
|
336
|
+
* setting override this; it is checked for every text sent, so it follows
|
|
337
|
+
* settings updates.
|
|
338
|
+
*
|
|
339
|
+
* @returns true in the base implementation.
|
|
340
|
+
*/
|
|
341
|
+
get supportsPronunciations(): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Create a text transform that makes this service say words as IPA describes.
|
|
344
|
+
*
|
|
345
|
+
* Each word is replaced with `formatPronunciation()` output, so the same
|
|
346
|
+
* IPA works with any service that supports it. Words the service cannot use
|
|
347
|
+
* are reported once and spoken as written. While the service cannot read
|
|
348
|
+
* pronunciation markup at all (see `supportsPronunciations`), the transform
|
|
349
|
+
* is skipped.
|
|
350
|
+
*
|
|
351
|
+
* Register this transform last in `textTransforms`. Transforms run in
|
|
352
|
+
* order, and one that runs after it (stripping markdown or symbols,
|
|
353
|
+
* replacing text) can rewrite the markup it inserts, such as Cartesia's
|
|
354
|
+
* `<<…>>` blocks or an SSML `<phoneme>` tag, and break the hint.
|
|
355
|
+
*
|
|
356
|
+
* @param pronunciations Word to IPA, e.g. `{ Metformin: "mɛtˈfɔɹmɪn" }`.
|
|
357
|
+
* @returns A transform to register with `textTransforms`.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* const pronounce = CartesiaTTSService.pronunciationTransformIpa({ Metformin: "mɛtˈfɔɹmɪn" });
|
|
361
|
+
* const tts = new CartesiaTTSService({
|
|
362
|
+
* textTransforms: [
|
|
363
|
+
* ["*", stripMarkdown],
|
|
364
|
+
* ["*", expandCurrency],
|
|
365
|
+
* ["*", pronounce], // last, so nothing rewrites its markup
|
|
366
|
+
* ],
|
|
367
|
+
* });
|
|
368
|
+
*/
|
|
369
|
+
static pronunciationTransformIpa(pronunciations: Readonly<Record<string, string>>): PronunciationTransform;
|
|
370
|
+
/**
|
|
371
|
+
* Run text-to-speech synthesis on the provided text.
|
|
372
|
+
*
|
|
373
|
+
* This method must be implemented by subclasses to provide actual TTS
|
|
374
|
+
* functionality. The base class logs the synthesized text before invoking
|
|
375
|
+
* this method, so implementations should not log it again.
|
|
376
|
+
*
|
|
377
|
+
* @param text The text to synthesize into speech.
|
|
378
|
+
* @param contextId Unique identifier for this TTS context.
|
|
379
|
+
* @returns Audio frames containing the synthesized speech.
|
|
380
|
+
*/
|
|
381
|
+
abstract runTts(text: string, contextId: string): AsyncGenerator<Frame | null, void>;
|
|
382
|
+
/**
|
|
383
|
+
* Convert a language to the service-specific language format.
|
|
384
|
+
*
|
|
385
|
+
* @param language The language to convert.
|
|
386
|
+
* @returns The service-specific language identifier. Return null to
|
|
387
|
+
* indicate an unsupported language. This optional return is an extension
|
|
388
|
+
* hook for future or third-party subclasses; as of 2026-04-28,
|
|
389
|
+
* first-party services return a string.
|
|
390
|
+
*/
|
|
391
|
+
languageToServiceLanguage(language: Language): string | null;
|
|
392
|
+
/**
|
|
393
|
+
* Generate or reuse a context ID based on concurrent TTS support.
|
|
394
|
+
*
|
|
395
|
+
* @returns A context ID string for the TTS request.
|
|
396
|
+
*/
|
|
397
|
+
createContextId(): string;
|
|
398
|
+
/**
|
|
399
|
+
* Flush any buffered audio data.
|
|
400
|
+
*
|
|
401
|
+
* @param contextId The specific context to flush. If null, falls back to
|
|
402
|
+
* the currently active context (for non-concurrent services).
|
|
403
|
+
*/
|
|
404
|
+
flushAudio(_contextId?: string | null): Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Process frames from an async generator, routing them through the audio context.
|
|
407
|
+
*
|
|
408
|
+
* All non-null frames yielded by the generator are appended to the audio
|
|
409
|
+
* context identified by contextId. The audio context must be created by
|
|
410
|
+
* runTts (via createAudioContext) before the first frame is yielded.
|
|
411
|
+
*
|
|
412
|
+
* WebSocket services yield null to signal that audio will arrive via a
|
|
413
|
+
* separate receive loop; those services manage context lifetime themselves
|
|
414
|
+
* (via removeAudioContext in the receive loop on "done"). HTTP services
|
|
415
|
+
* never yield null and do NOT call removeAudioContext in runTts —
|
|
416
|
+
* onTurnContextCompleted closes the context once the turn's remaining
|
|
417
|
+
* frames (e.g. TTSTextFrame) are queued.
|
|
418
|
+
*
|
|
419
|
+
* @param contextId The audio context to route frames to.
|
|
420
|
+
* @param generator An async generator yielding Frame objects or null.
|
|
421
|
+
*/
|
|
422
|
+
ttsProcessGenerator(contextId: string, generator: AsyncIterable<Frame | null | undefined>): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Called when a new turn context ID has been created.
|
|
425
|
+
*
|
|
426
|
+
* Override to perform provider-specific setup (e.g., eagerly opening a
|
|
427
|
+
* server-side context) before text starts flowing. This is called from
|
|
428
|
+
* `processFrame` when an `LLMFullResponseStartFrame` or `TTSSpeakFrame`
|
|
429
|
+
* arrives.
|
|
430
|
+
*
|
|
431
|
+
* @param contextId The newly created turn context ID.
|
|
432
|
+
*/
|
|
433
|
+
onTurnContextCreated(_contextId: string): Promise<void>;
|
|
434
|
+
/** Handle the completion of a turn. */
|
|
435
|
+
onTurnContextCompleted(): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* Called when an audio context is cancelled due to an interruption.
|
|
438
|
+
*
|
|
439
|
+
* Override this in a subclass to perform provider-specific cleanup (e.g.
|
|
440
|
+
* sending a cancel/close message over the WebSocket) when the bot is
|
|
441
|
+
* interrupted mid-speech. The context is still registered when this hook
|
|
442
|
+
* runs. Uninterruptible contexts continue playing and do not call this
|
|
443
|
+
* hook.
|
|
444
|
+
*
|
|
445
|
+
* @param contextId The ID of the audio context that was interrupted.
|
|
446
|
+
*/
|
|
447
|
+
onAudioContextInterrupted(_contextId: string): Promise<void>;
|
|
448
|
+
/**
|
|
449
|
+
* Called after an audio context has finished playing all of its audio.
|
|
450
|
+
*
|
|
451
|
+
* Override this in a subclass to perform provider-specific cleanup (e.g.
|
|
452
|
+
* sending a close-context message to free server-side resources) once an
|
|
453
|
+
* audio context has been fully processed. The context entry has already
|
|
454
|
+
* been removed from the internal context map, and the active context has
|
|
455
|
+
* **not** yet been reset when this is called.
|
|
456
|
+
*
|
|
457
|
+
* @param contextId The ID of the audio context that finished processing.
|
|
458
|
+
*/
|
|
459
|
+
onAudioContextCompleted(_contextId: string): Promise<void>;
|
|
460
|
+
/** Start tracking word timestamps from the current time. */
|
|
461
|
+
startWordTimestamps(): Promise<void>;
|
|
462
|
+
/** Reset word timestamp tracking. */
|
|
463
|
+
resetWordTimestamps(): Promise<void>;
|
|
464
|
+
/**
|
|
465
|
+
* Add word timestamps for processing.
|
|
466
|
+
*
|
|
467
|
+
* When an audio context exists for this contextId, timestamps are routed
|
|
468
|
+
* into the per-context audio queue alongside audio frames so they are
|
|
469
|
+
* processed in strict playback order by _handleAudioContext. Otherwise they
|
|
470
|
+
* are processed immediately via _addWordTimestamps.
|
|
471
|
+
*
|
|
472
|
+
* @param wordTimes List of [word, timestamp] tuples where timestamp is in
|
|
473
|
+
* seconds.
|
|
474
|
+
* @param contextId Unique identifier for the TTS context.
|
|
475
|
+
* @param options.includesInterFrameSpaces When true, each emitted
|
|
476
|
+
* TTSTextFrame carries `includesInterFrameSpaces=true` so downstream
|
|
477
|
+
* consumers do not inject extra spaces between consecutive frames (e.g.
|
|
478
|
+
* ElevenLabs for CJK languages where word tokens already self-contain
|
|
479
|
+
* their spacing). null leaves the frame's own default unchanged.
|
|
480
|
+
* @param options.preMergeTokens When true, punctuation and space-only
|
|
481
|
+
* tokens are merged into the preceding word via `mergePunctTokens` before
|
|
482
|
+
* queuing (e.g. Inworld TTS, which emits spaces and punctuation as
|
|
483
|
+
* separate tokens). After merging the resulting tokens are clean word
|
|
484
|
+
* strings, so `includesInterFrameSpaces` should be left false (its
|
|
485
|
+
* default).
|
|
486
|
+
*/
|
|
487
|
+
addWordTimestamps(wordTimes: (readonly [string, number])[], contextId?: string | null, options?: {
|
|
488
|
+
includesInterFrameSpaces?: boolean | null;
|
|
489
|
+
preMergeTokens?: boolean;
|
|
490
|
+
}): Promise<void>;
|
|
491
|
+
/**
|
|
492
|
+
* Create a new audio context for grouping related audio.
|
|
493
|
+
*
|
|
494
|
+
* @param contextId Unique identifier for the audio context.
|
|
495
|
+
*/
|
|
496
|
+
createAudioContext(contextId: string): Promise<void>;
|
|
497
|
+
/**
|
|
498
|
+
* Append a frame or word-timestamp entry to an existing audio context queue.
|
|
499
|
+
*
|
|
500
|
+
* Passing a `frame` of null signals end-of-context (used by
|
|
501
|
+
* removeAudioContext to mark the queue for deletion). If the context no
|
|
502
|
+
* longer exists but the contextId matches the active turn, the context is
|
|
503
|
+
* transparently recreated before appending.
|
|
504
|
+
*
|
|
505
|
+
* @param contextId The context to append to. null is accepted as a no-op
|
|
506
|
+
* (with a debug log) so callers can pass through values from
|
|
507
|
+
* `getActiveAudioContextId()` without an explicit guard.
|
|
508
|
+
* @param frame The frame, word-timestamp entry, or null (end-of-context
|
|
509
|
+
* sentinel) to append.
|
|
510
|
+
*/
|
|
511
|
+
appendToAudioContext(contextId: string | null, frame: AudioContextItem | null): Promise<void>;
|
|
512
|
+
/**
|
|
513
|
+
* Remove an existing audio context.
|
|
514
|
+
*
|
|
515
|
+
* @param contextId The context to remove. null is accepted as a no-op
|
|
516
|
+
* (logged) so callers can pass through values from
|
|
517
|
+
* `getActiveAudioContextId()` without an explicit guard.
|
|
518
|
+
*/
|
|
519
|
+
removeAudioContext(contextId: string | null): Promise<void>;
|
|
520
|
+
/**
|
|
521
|
+
* Check whether the given audio context is registered.
|
|
522
|
+
*
|
|
523
|
+
* @param contextId The context ID to check.
|
|
524
|
+
* @returns true if the context exists and is available.
|
|
525
|
+
*/
|
|
526
|
+
audioContextAvailable(contextId: string): boolean;
|
|
527
|
+
/** Get a list of all available audio contexts. */
|
|
528
|
+
getAudioContexts(): string[];
|
|
529
|
+
/**
|
|
530
|
+
* Check if there is an active audio context.
|
|
531
|
+
*
|
|
532
|
+
* @returns true if an active audio context exists, false otherwise.
|
|
533
|
+
*/
|
|
534
|
+
hasActiveAudioContext(): boolean;
|
|
535
|
+
/**
|
|
536
|
+
* Get the active audio context ID.
|
|
537
|
+
*
|
|
538
|
+
* Returns the playback cursor when set (during active playback), falling
|
|
539
|
+
* back to the current turn's synthesis contextId. The fallback covers the
|
|
540
|
+
* gap between contexts and the start of a turn before the playback task has
|
|
541
|
+
* dequeued the just-created context — important for services whose wire
|
|
542
|
+
* protocol does not echo contextId back on incoming audio.
|
|
543
|
+
*
|
|
544
|
+
* @returns The active context ID, or null if neither cursor is set.
|
|
545
|
+
*/
|
|
546
|
+
getActiveAudioContextId(): string | null;
|
|
547
|
+
/** Remove the active audio context. */
|
|
548
|
+
removeActiveAudioContext(): Promise<void>;
|
|
549
|
+
/** Reset the active audio context. */
|
|
550
|
+
resetActiveAudioContext(): void;
|
|
551
|
+
/**
|
|
552
|
+
* Process frames for text-to-speech conversion.
|
|
553
|
+
*
|
|
554
|
+
* Handles TextFrames for synthesis, interruption frames, settings updates,
|
|
555
|
+
* and various control frames.
|
|
556
|
+
*
|
|
557
|
+
* @param frame The frame to process.
|
|
558
|
+
* @param direction The direction of frame processing.
|
|
559
|
+
*/
|
|
560
|
+
processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
|
|
561
|
+
/**
|
|
562
|
+
* Push a frame downstream with TTS-specific handling.
|
|
563
|
+
*
|
|
564
|
+
* @param frame The frame to push.
|
|
565
|
+
* @param direction The direction to push the frame.
|
|
566
|
+
*/
|
|
567
|
+
pushFrame(frame: Frame, direction?: FrameDirection): Promise<void>;
|
|
568
|
+
/**
|
|
569
|
+
* Apply a TTS settings delta.
|
|
570
|
+
*
|
|
571
|
+
* Translates language to service-specific value before applying.
|
|
572
|
+
*
|
|
573
|
+
* @param delta A TTS settings delta.
|
|
574
|
+
* @returns Record mapping changed field names to their previous values.
|
|
575
|
+
*/
|
|
576
|
+
protected _updateSettings(delta: TTSSettings): Promise<Record<string, unknown>>;
|
|
577
|
+
/** Convert a language to the service's format, passing unknown codes as they are. */
|
|
578
|
+
protected _serviceLanguage(language: string): string;
|
|
579
|
+
/** Start a turn whose sentences share one context ID. */
|
|
580
|
+
protected _handleLlmResponseStart(frame: LLMFullResponseStartFrame): Promise<void>;
|
|
581
|
+
/** Speak the turn's remaining text and complete the turn. */
|
|
582
|
+
protected _handleLlmResponseEnd(frame: LLMFullResponseEndFrame | EndFrame, direction: FrameDirection): Promise<void>;
|
|
583
|
+
/** Queue each sentence of LLM text that isn't spoken. */
|
|
584
|
+
protected _handleSkippedLlmText(frame: LLMTextFrame): Promise<void>;
|
|
585
|
+
/** Queue the rest of a reply that isn't spoken, then the end of the reply. */
|
|
586
|
+
protected _handleSkippedLlmResponseEnd(frame: LLMFullResponseEndFrame): Promise<void>;
|
|
587
|
+
/** Queue a sentence of LLM text that isn't spoken, as the bot's output. */
|
|
588
|
+
protected _queueSkippedLlmText(aggregation: Aggregation): Promise<void>;
|
|
589
|
+
/** Speak a TTSSpeakFrame as a turn of its own, even in the middle of an LLM turn. */
|
|
590
|
+
protected _handleTtsSpeak(frame: TTSSpeakFrame): Promise<void>;
|
|
591
|
+
/** Apply a settings update meant for this service, or pass it on. */
|
|
592
|
+
protected _handleUpdateSettings(frame: TTSUpdateSettingsFrame, direction: FrameDirection): Promise<void>;
|
|
593
|
+
/** Reset the turn and drop interruptible audio contexts. */
|
|
594
|
+
protected _handleInterruption(_frame: InterruptionFrame, _direction: FrameDirection): Promise<void>;
|
|
595
|
+
/** Discard interruptible contexts while preserving ongoing synthesis and playback. */
|
|
596
|
+
protected _interruptAudioContexts(): Promise<void>;
|
|
597
|
+
/**
|
|
598
|
+
* Hold incoming frames while an audio context is open.
|
|
599
|
+
*
|
|
600
|
+
* Services whose audio doesn't carry its request's context ID label
|
|
601
|
+
* incoming audio with the context still open, so the next request waits for
|
|
602
|
+
* every open context to end. Contexts play in order, so audio from
|
|
603
|
+
* different requests never overlaps.
|
|
604
|
+
*/
|
|
605
|
+
protected _holdFramesWhileAudioContextsOpen(): Promise<void>;
|
|
606
|
+
/** Let held frames through once no audio context is open. */
|
|
607
|
+
protected _releaseFramesIfAudioContextsEnded(): Promise<void>;
|
|
608
|
+
/** Make a frame of an uninterruptible context uninterruptible too. */
|
|
609
|
+
protected _applyContextInterruptible(frame: Frame): void;
|
|
610
|
+
/** Forget a stopped context and push the assistant aggregation it asked for. */
|
|
611
|
+
protected _finishTtsContext(frame: TTSStoppedFrame): Promise<void>;
|
|
612
|
+
/** Push the silence configured to follow a TTSStoppedFrame. */
|
|
613
|
+
protected _pushStopSilence(frame: TTSStoppedFrame): Promise<void>;
|
|
614
|
+
/** Send a segment's willBeSpoken frame through the transport's clock queue. */
|
|
615
|
+
protected _stampSegmentAnnouncement(frame: AggregatedTextFrame): void;
|
|
616
|
+
/** Whether the service is streaming tokens directly without sentence aggregation. */
|
|
617
|
+
protected get _isStreamingTokens(): boolean;
|
|
618
|
+
/** Aggregate LLM text and speak each aggregation. */
|
|
619
|
+
protected _handleText(frame: TextFrame): Promise<void>;
|
|
620
|
+
/** Build the frame for an aggregation, keeping a pattern's delimiters in its raw text. */
|
|
621
|
+
protected _aggregatedTextFrame(aggregation: Aggregation): AggregatedTextFrame;
|
|
622
|
+
/** Speak aggregated text in `contextId` or a new context, or push it on if skipped. */
|
|
623
|
+
protected _handleAggregatedText(srcFrame: AggregatedTextFrame, contextId?: string | null): Promise<void>;
|
|
624
|
+
/** Push text that isn't spoken, in order with the spoken text around it. */
|
|
625
|
+
protected _pushSkippedText(frame: AggregatedTextFrame, contextId: string): Promise<void>;
|
|
626
|
+
/** Filter, transform and synthesize text, timing it as processing. */
|
|
627
|
+
protected _speakText(srcFrame: AggregatedTextFrame, text: string, contextId: string): Promise<void>;
|
|
628
|
+
/** Trim leading whitespace from text to synthesize, or null if nothing is left to say. */
|
|
629
|
+
protected _trimText(text: string): string | null;
|
|
630
|
+
/**
|
|
631
|
+
* Run the text filters on text about to be synthesized.
|
|
632
|
+
*
|
|
633
|
+
* @returns The filtered text, or null if nothing is left to say.
|
|
634
|
+
*/
|
|
635
|
+
protected _filterText(text: string): Promise<string | null>;
|
|
636
|
+
/**
|
|
637
|
+
* Turn filtered text into the text sent to the TTS.
|
|
638
|
+
*
|
|
639
|
+
* Transforms only affect the text sent to the TTS for TTS-specific purposes
|
|
640
|
+
* (e.g. inserting tags for spelling or emotion, or replacing an @ with
|
|
641
|
+
* "at"). For services with word timestamps they can affect the context,
|
|
642
|
+
* since TTSTextFrames are built from the TTS output.
|
|
643
|
+
*
|
|
644
|
+
* @returns The text to synthesize, or null if a transform failed.
|
|
645
|
+
*/
|
|
646
|
+
protected _transformText(text: string, textType: string): Promise<string | null>;
|
|
647
|
+
/** Whether pronunciation transforms apply, warning once when they stop applying. */
|
|
648
|
+
protected _canApplyPronunciations(): boolean;
|
|
649
|
+
/**
|
|
650
|
+
* Prepare text for TTS by applying any transformations required by the TTS service.
|
|
651
|
+
*
|
|
652
|
+
* @param text The text to prepare.
|
|
653
|
+
* @returns The prepared text with transformations applied.
|
|
654
|
+
*/
|
|
655
|
+
protected _prepareTextForTts(text: string): string;
|
|
656
|
+
/** Mark text as about to be spoken and push it ahead of its audio. */
|
|
657
|
+
protected _announceText(srcFrame: AggregatedTextFrame, contextId: string): Promise<void>;
|
|
658
|
+
/** Open an audio context with a TTSStartedFrame, for services that leave it to the base. */
|
|
659
|
+
protected _startAudioContext(contextId: string): Promise<void>;
|
|
660
|
+
/** Give the text a slot in the sequencer, which orders it with skipped text. */
|
|
661
|
+
protected _registerSpokenText(srcFrame: AggregatedTextFrame, text: string, contextId: string): Promise<void>;
|
|
662
|
+
/**
|
|
663
|
+
* Emit frames returned by the aggregated-frame sequencer in audio order.
|
|
664
|
+
*
|
|
665
|
+
* In streaming (TOKEN) mode these frames — a promoted sentence anchor and
|
|
666
|
+
* any replayed word/progress frames — describe an audio context whose audio
|
|
667
|
+
* and word frames are emitted by the dedicated audio-context task. Routing
|
|
668
|
+
* them through that context's queue keeps a single consumer emitting
|
|
669
|
+
* everything in order; pushing directly here would let them race the
|
|
670
|
+
* audio-context task. When the context is gone (or the sequencer is
|
|
671
|
+
* non-streaming), push directly.
|
|
672
|
+
*
|
|
673
|
+
* @param frames Frames returned by registerSpoken/registerSkipped/finalize.
|
|
674
|
+
* @param contextId The context these frames belong to.
|
|
675
|
+
*/
|
|
676
|
+
protected _pushSequencerFrames(frames: Frame[], contextId: string | null): Promise<void>;
|
|
677
|
+
/** Run the service's runTts for text, unless the service is no longer usable. */
|
|
678
|
+
protected _synthesizeText(text: string, contextId: string): Promise<void>;
|
|
679
|
+
/** Queue the spoken text behind its audio, for services without word timestamps. */
|
|
680
|
+
protected _pushSpokenText(srcFrame: AggregatedTextFrame, text: string, contextId: string, appendToContext: boolean): Promise<void>;
|
|
681
|
+
/**
|
|
682
|
+
* Stream audio frames from an async byte iterator with optional resampling.
|
|
683
|
+
*
|
|
684
|
+
* For WAV data, use `stripWavHeader: true` to strip the header and
|
|
685
|
+
* auto-detect the source sample rate. For raw PCM data, pass `inSampleRate`
|
|
686
|
+
* directly. Audio is resampled to `this.sampleRate` when the source rate
|
|
687
|
+
* differs.
|
|
688
|
+
*
|
|
689
|
+
* @param iterator Async iterator yielding audio bytes.
|
|
690
|
+
* @param options.stripWavHeader Strip WAV header and parse source sample
|
|
691
|
+
* rate from it.
|
|
692
|
+
* @param options.inSampleRate Source sample rate for raw PCM data.
|
|
693
|
+
* Overrides WAV-detected rate if both are provided.
|
|
694
|
+
* @param options.contextId Unique identifier for this TTS context.
|
|
695
|
+
*/
|
|
696
|
+
protected _streamAudioFramesFromIterator(iterator: AsyncIterable<Uint8Array>, options?: {
|
|
697
|
+
stripWavHeader?: boolean;
|
|
698
|
+
inSampleRate?: number | null;
|
|
699
|
+
contextId?: string | null;
|
|
700
|
+
}): AsyncGenerator<Frame, void>;
|
|
701
|
+
/**
|
|
702
|
+
* Process word timestamps directly, building and pushing TTSTextFrames inline.
|
|
703
|
+
*
|
|
704
|
+
* Used both from _handleAudioContext (via WordTimestamp items) and from
|
|
705
|
+
* services that do not use audio contexts. Each entry emits a TTSTextFrame
|
|
706
|
+
* with a PTS relative to when startWordTimestamps() was called. Entries that
|
|
707
|
+
* come before that are cached and timed once it is called (i.e. when the
|
|
708
|
+
* first audio chunk is received).
|
|
709
|
+
*/
|
|
710
|
+
protected _addWordTimestamps(wordTimes: readonly (readonly [string, number])[], contextId?: string | null, options?: {
|
|
711
|
+
includesInterFrameSpaces?: boolean;
|
|
712
|
+
}): Promise<void>;
|
|
713
|
+
/** Push frames built by the sequencer, noting the PTS of the last word. */
|
|
714
|
+
protected _pushWordFrames(frames: Frame[]): Promise<void>;
|
|
715
|
+
/**
|
|
716
|
+
* Force-complete a context's spoken slots and push any unblocked skipped frames.
|
|
717
|
+
*
|
|
718
|
+
* Called at end-of-context to handle TTS providers that silently drop
|
|
719
|
+
* word-timestamp events. Emits a TTSTextFrame for any remaining unspoken
|
|
720
|
+
* text in this context, then flushes skipped frames that were blocked by
|
|
721
|
+
* those incomplete slots. Slots for other contexts still in flight are left
|
|
722
|
+
* untouched.
|
|
723
|
+
*
|
|
724
|
+
* @param contextId The audio context that has ended.
|
|
725
|
+
*/
|
|
726
|
+
protected _applyForceComplete(contextId: string): Promise<void>;
|
|
727
|
+
/** Signal that the audio context is still in use, resetting the timeout. */
|
|
728
|
+
protected _refreshAudioContext(contextId: string): void;
|
|
729
|
+
/** Create the task that plays audio contexts. */
|
|
730
|
+
protected _createAudioContextTask(): void;
|
|
731
|
+
/** Cancel the task that plays audio contexts. */
|
|
732
|
+
protected _stopAudioContextTask(): Promise<void>;
|
|
733
|
+
/**
|
|
734
|
+
* Play audio contexts and the frames between them in order.
|
|
735
|
+
*
|
|
736
|
+
* Each audio context plays until all its audio has been pushed downstream,
|
|
737
|
+
* then onAudioContextCompleted() is called. A frame between contexts (e.g.
|
|
738
|
+
* an AggregatedTextFrame preceding its audio, or a frame that arrived
|
|
739
|
+
* between two speak frames) is pushed at its position.
|
|
740
|
+
*/
|
|
741
|
+
protected _audioContextTaskHandler(): Promise<void>;
|
|
742
|
+
/** Send a reply's end frame after its words, or behind its start frame if it timed none. */
|
|
743
|
+
protected _stampLlmResponseFrame(frame: Frame): void;
|
|
744
|
+
/** Push an audio context's items in order until it ends or goes quiet. */
|
|
745
|
+
protected _handleAudioContext(contextId: string): Promise<void>;
|
|
746
|
+
/** Wait for the context's next item, or null once it ends or goes quiet. */
|
|
747
|
+
protected _nextAudioContextItem(contextId: string): Promise<AudioContextItem | null>;
|
|
748
|
+
/** Push one item of the playing audio context. */
|
|
749
|
+
protected _pushAudioContextItem(contextId: string, item: AudioContextItem, playback: _AudioContextPlayback): Promise<void>;
|
|
750
|
+
/** Finish the playing audio context once it ends or goes quiet. */
|
|
751
|
+
protected _endAudioContext(contextId: string, playback: _AudioContextPlayback): Promise<void>;
|
|
752
|
+
/**
|
|
753
|
+
* Track whether contexts are producing audio, and act when they stop.
|
|
754
|
+
*
|
|
755
|
+
* A provider can accept every request and return no audio at all — an
|
|
756
|
+
* unknown voice ID, say — without ever reporting an error. Every context
|
|
757
|
+
* that completes in silence is reported as an error, so application code
|
|
758
|
+
* hears about a turn that produced no speech as it happens. Enough of them
|
|
759
|
+
* in a row means the service isn't going to speak again, so it is reported
|
|
760
|
+
* unable to do its job: it stops being given work, a `ServiceSwitcher` can
|
|
761
|
+
* fail over to another provider, and the pipeline worker applies its
|
|
762
|
+
* `ProcessorUnusablePolicy`.
|
|
763
|
+
*
|
|
764
|
+
* Only contexts that complete are counted; an interrupted context is
|
|
765
|
+
* cancelled before it gets here.
|
|
766
|
+
*
|
|
767
|
+
* @param contextId The audio context that just completed.
|
|
768
|
+
* @param receivedAudio Whether any audio arrived for that context.
|
|
769
|
+
*/
|
|
770
|
+
protected _recordContextAudioOutcome(contextId: string, receivedAudio: boolean): Promise<void>;
|
|
771
|
+
}
|
|
772
|
+
export interface WebsocketTTSServiceOptions extends TTSServiceOptions, WebsocketServiceOptions {
|
|
773
|
+
}
|
|
774
|
+
declare const WebsocketTTSService_base: typeof TTSService & (abstract new (...args: any[]) => WebsocketService);
|
|
775
|
+
/**
|
|
776
|
+
* Base class for websocket-based TTS services.
|
|
777
|
+
*
|
|
778
|
+
* Combines TTS functionality with websocket connectivity, providing automatic
|
|
779
|
+
* error handling and reconnection capabilities.
|
|
780
|
+
*
|
|
781
|
+
* Includes an optional keepalive for providers that close an idle
|
|
782
|
+
* connection. A subclass enables it by overriding `_sendKeepalive()` to send
|
|
783
|
+
* its provider's keepalive message, and calling
|
|
784
|
+
* `_createKeepaliveTask(interval)` / `_cancelKeepaliveTask()` from its
|
|
785
|
+
* `_connect()` / `_disconnect()`.
|
|
786
|
+
*
|
|
787
|
+
* Event handlers:
|
|
788
|
+
*
|
|
789
|
+
* - on_connection_error: Called when a websocket connection error occurs.
|
|
790
|
+
*
|
|
791
|
+
* @example
|
|
792
|
+
* tts.eventHandler("on_connection_error", async (tts: TTSService, error: string) => {
|
|
793
|
+
* logger.error(`TTS connection error: ${error}`);
|
|
794
|
+
* });
|
|
795
|
+
*/
|
|
796
|
+
export declare abstract class WebsocketTTSService extends WebsocketTTSService_base {
|
|
797
|
+
protected _keepaliveTask: Task<unknown> | null;
|
|
798
|
+
/**
|
|
799
|
+
* Initialize the Websocket TTS service.
|
|
800
|
+
*
|
|
801
|
+
* @param options.reconnectOnError Whether to automatically reconnect on
|
|
802
|
+
* websocket errors. Other options are passed to parent classes.
|
|
803
|
+
*/
|
|
804
|
+
constructor(options?: WebsocketTTSServiceOptions);
|
|
805
|
+
/**
|
|
806
|
+
* Whether this service has a meaningful processing-time metric.
|
|
807
|
+
*
|
|
808
|
+
* false: `runTts` sends the text and returns, and audio arrives later on
|
|
809
|
+
* the receive task, so there is no synthesis inside the measured window. A
|
|
810
|
+
* subclass that instead waits for the server to signal the end of synthesis
|
|
811
|
+
* before returning can override this back to true.
|
|
812
|
+
*/
|
|
813
|
+
get supportsProcessingMetrics(): boolean;
|
|
814
|
+
/**
|
|
815
|
+
* Stop the websocket TTS service on a graceful end.
|
|
816
|
+
*
|
|
817
|
+
* @param frame The end frame.
|
|
818
|
+
*/
|
|
819
|
+
stop(frame: EndFrame): Promise<void>;
|
|
820
|
+
/**
|
|
821
|
+
* Cancel the websocket TTS service immediately.
|
|
822
|
+
*
|
|
823
|
+
* Disconnecting here is the prompt teardown: the websocket receive loop
|
|
824
|
+
* runs independently of the audio-context task, so it keeps reading from
|
|
825
|
+
* the provider until the socket is closed. Stopping only the audio-context
|
|
826
|
+
* task (in `TTSService.cancel()`) halts output but not reception.
|
|
827
|
+
*
|
|
828
|
+
* @param frame The cancel frame.
|
|
829
|
+
*/
|
|
830
|
+
cancel(frame: CancelFrame): Promise<void>;
|
|
831
|
+
/** Release websocket TTS resources at teardown. */
|
|
832
|
+
cleanup(): Promise<void>;
|
|
833
|
+
/**
|
|
834
|
+
* End the audio contexts of a connection that is being replaced.
|
|
835
|
+
*
|
|
836
|
+
* Providers keep context state per connection and don't resume it on a new
|
|
837
|
+
* one, so audio still due on the old connection never arrives. Every open
|
|
838
|
+
* context is closed (audio already received still plays), and a turn in
|
|
839
|
+
* progress moves to a new context ID so its remaining sentences open a
|
|
840
|
+
* fresh provider context. Reopening a connection that was already closed,
|
|
841
|
+
* to send the text at hand, doesn't come through here, so the context it
|
|
842
|
+
* sends to stays open.
|
|
843
|
+
*/
|
|
844
|
+
protected _closeConnectionContexts(): Promise<void>;
|
|
845
|
+
_disconnect(): Promise<void>;
|
|
846
|
+
_reconnectWebsocket(attemptNumber: number): Promise<boolean>;
|
|
847
|
+
protected _reportError(error: ErrorFrame, options?: {
|
|
848
|
+
forceTreatAsPermanent?: boolean;
|
|
849
|
+
}): Promise<void>;
|
|
850
|
+
/**
|
|
851
|
+
* Start the keepalive task if it isn't running.
|
|
852
|
+
*
|
|
853
|
+
* @param interval Seconds between keepalive messages.
|
|
854
|
+
*/
|
|
855
|
+
protected _createKeepaliveTask(interval: number): void;
|
|
856
|
+
/** Stop the keepalive task if running. */
|
|
857
|
+
protected _cancelKeepaliveTask(): Promise<void>;
|
|
858
|
+
/**
|
|
859
|
+
* Send a keepalive every `interval` seconds while connected.
|
|
860
|
+
*
|
|
861
|
+
* A failed send is logged and the loop keeps going: the receive loop
|
|
862
|
+
* handles a lost connection, and the next keepalive goes out on the
|
|
863
|
+
* reconnected socket.
|
|
864
|
+
*/
|
|
865
|
+
protected _keepaliveTaskHandler(interval: number): Promise<void>;
|
|
866
|
+
/**
|
|
867
|
+
* Check if the service is ready to send a keepalive.
|
|
868
|
+
*
|
|
869
|
+
* @returns true if the websocket is open.
|
|
870
|
+
*/
|
|
871
|
+
protected _isKeepaliveReady(): boolean;
|
|
872
|
+
/**
|
|
873
|
+
* Send a keepalive message over the websocket.
|
|
874
|
+
*
|
|
875
|
+
* Subclasses that enable keepalive must override this to send their
|
|
876
|
+
* provider's keepalive message.
|
|
877
|
+
*/
|
|
878
|
+
protected _sendKeepalive(): Promise<void>;
|
|
879
|
+
}
|
|
880
|
+
export interface InterruptibleTTSServiceOptions extends WebsocketTTSServiceOptions {
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Websocket-based TTS service that handles interruptions without word timestamps.
|
|
884
|
+
*
|
|
885
|
+
* Designed for TTS services that don't support word timestamps. Handles
|
|
886
|
+
* interruptions by reconnecting the websocket when the bot is speaking and
|
|
887
|
+
* gets interrupted.
|
|
888
|
+
*/
|
|
889
|
+
export declare abstract class InterruptibleTTSService extends WebsocketTTSService {
|
|
890
|
+
protected _botSpeaking: boolean;
|
|
891
|
+
protected _ttsStarted: boolean;
|
|
892
|
+
protected _handleInterruption(frame: InterruptionFrame, direction: FrameDirection): Promise<void>;
|
|
893
|
+
/**
|
|
894
|
+
* Push a frame downstream with TTS-specific handling.
|
|
895
|
+
*
|
|
896
|
+
* @param frame The frame to push.
|
|
897
|
+
* @param direction The direction to push the frame.
|
|
898
|
+
*/
|
|
899
|
+
pushFrame(frame: Frame, direction?: FrameDirection): Promise<void>;
|
|
900
|
+
/**
|
|
901
|
+
* Process frames, tracking whether an interruption needs a reconnect.
|
|
902
|
+
*
|
|
903
|
+
* @param frame The frame to process.
|
|
904
|
+
* @param direction The direction of frame processing.
|
|
905
|
+
*/
|
|
906
|
+
processFrame(frame: Frame, direction: FrameDirection): Promise<void>;
|
|
907
|
+
}
|
|
908
|
+
export {};
|
|
909
|
+
//# sourceMappingURL=tts_service.d.ts.map
|