npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pipecat-ai/realtime-websocket-transport

v0.3.4

Published

Pipecat Base Transport for RealTime WebSocket APIs Package

Downloads

634

Readme

Real-Time Websocket Transport

Docs Demo NPM Version

A flexible abstract transport class for implementing connections to directly communicate with LLMs that support voice-to-voice modalities.

Installation

npm install \
@pipecat-ai/client-js \
@pipecat-ai/real-time-websocket-transport

Overview

The RealTimeWebsocketTransport class provides a foundation for building transports for direct voice-to-voice communication:

  • Audio/video device management
  • Bi-directional audio streaming
  • Device selection and control
  • State management
  • Event handling

Disclaimer

This Transport type is primarily intended for dev-only and testing purposes. Since this transport talks directly with the LLM, there is no way to obscure API Keys necessary for doing so. Developers will need to eventually build a server component with a server-friendly transport (See the daily-transport as an example.)

Usage

To use this package, create a new Transport by extending the RealTimeWebsocketTransport class and implement the following abstract functions:

import { RealTimeWebsocketTransport } from '@pipecat-ai/real-time-websocket-transport';

export interface MyLLMOptions extends LLMServiceOptions {
    api_key: string,
    // define types for all the various options your
    // LLM service may want to support during setup/connection
}

class MyLLMServiceTransport extends RealTimeWebsocketTransport {
  constructor(service_options: GeminiLLMServiceOptions, manager?: MediaManager) {
    super(service_options, manager);
    // Initialize class variables
  }

async initializeLLM(): void {
    // Initialize your LLM service client
  }

  async attachLLMListeners(): void {
    // Set up event listeners to handle message from your LLM service
  }

  async connectLLM(): Promise<void> {
    // Implement connection logic for the LLM
  }

  async disconnectLLM(): Promise<void> {
    // Disconnect from the LLM
  }

  handleUserAudioStream(data: ArrayBuffer): void {
    // Pass the data provided to the LLM
  }

  async sendReadyMessage(): Promise<void> {
    // call this._onMessage() with a BOT_READY message once the
    // LLM is connected and ready to receive data
  }

  sendMessage(message: RTVIMessage): void {
    // Implement sending other LLM-specific messages to the LLM
    // This is how the user can call things like rtviClient.sendMessage(...)
    // and communicate in other ways with the LLM
  }
}

API Reference

Constructor

constructor(service_options: LLMServiceOptions, manager: MediaManager)

Abstract Methods

  • initializeLLM(): void
  • attachLLMListeners(): void
  • connectLLM(): Promise<void>
  • disconnectLLM(): Promise<void>
  • handleUserAudioStream(data: ArrayBuffer): void
  • sendReadyMessage()
  • sendMessage(message: RTVIMessage)

Device Management Methods

  • getAllMics(): Promise<MediaDeviceInfo[]>
  • getAllCams(): Promise<MediaDeviceInfo[]>
  • getAllSpeakers(): Promise<MediaDeviceInfo[]>
  • updateMic(micId: string): Promise<void>
  • updateCam(camId: string): void
  • updateSpeaker(speakerId: string): void

State Properties

  • get state(): TransportState
  • get isCamEnabled(): boolean
  • get isMicEnabled(): boolean

Events

The transport supports emitting the events defined by the RTVI Specification

License

BSD-2 Clause