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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jona27/livetalking-streaming-sdk

v1.0.0

Published

Streaming Avatar SDK for LiveTalking with Wav2Lip - JavaScript Version

Downloads

4

Readme

LiveTalking Streaming SDK

A Node.js SDK for streaming avatars using LiveTalking with Wav2Lip technology, fully compatible with your enhanced streaming API backend.

Installation

npm install @jona27/livetalking-streaming-sdk

Quick Start

const { StreamingAvatar } = require('@jona27/livetalking-streaming-sdk');

async function main() {
  // Initialize the streaming avatar
  const avatar = new StreamingAvatar({
    serverUrl: 'http://localhost:8010', // Your LiveTalking server URL
    debug: true
  });

  try {
    // Create authentication token
    await avatar.createToken({ user_id: 'your_user_id' });
    
    // Create and start avatar session
    const sessionData = await avatar.createStartAvatar({
      avatarId: 'wav2lip256_avatar1', // Your avatar ID
      quality: 'medium'
    });
    
    console.log('Session created:', sessionData.sessionId);

    // Set up event listeners
    avatar.on('avatar_start_talking', (text) => {
      console.log('Avatar started talking:', text);
    });

    avatar.on('stream_ready', (data) => {
      console.log('Stream ready:', data.sessionId);
    });

    // Make avatar speak
    await avatar.speak({
      text: 'Hello! This is your streaming avatar.',
      interrupt: false
    });

    // Interrupt current speech
    await avatar.interrupt();

    // Close session when done
    await avatar.closeAvatar();
    
  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();

API Reference

StreamingAvatar

Constructor

new StreamingAvatar(config)

Parameters:

  • config.serverUrl (string): Your LiveTalking server URL
  • config.token (string, optional): Pre-existing authentication token
  • config.debug (boolean, optional): Enable debug logging

Methods

createToken(request?)

Creates an authentication token for API access.

Parameters:

  • request.user_id (string, optional): User identifier

Returns: Promise

createStartAvatar(request)

Creates and starts an avatar session with WebSocket connection.

Parameters:

  • request.avatarId (string): Avatar ID (e.g., 'wav2lip256_avatar1')
  • request.quality ('low' | 'medium' | 'high', optional): Video quality
  • request.voice (object, optional): Voice configuration
  • request.knowledgeBase (string, optional): Knowledge base for LLM

Returns: Promise

startSession()

Starts an existing session (if not auto-started).

speak(request)

Makes the avatar speak text via WebSocket or HTTP.

Parameters:

  • request.text (string): Text to speak
  • request.interrupt (boolean, optional): Whether to interrupt current speech
interrupt()

Interrupts current avatar speech.

closeAvatar()

Closes the avatar session and cleans up resources.

getSessionId()

Gets the current session ID.

Returns: string | null

isAvatarConnected()

Checks if avatar is connected via WebSocket.

Returns: boolean

sendWebRTCOffer(sdp)

Sends WebRTC offer for direct video streaming.

Parameters:

  • sdp (string): WebRTC SDP offer
ping()

Sends ping to keep WebSocket connection alive.

Events

  • avatar_start_talking: Fired when avatar starts speaking with text
  • avatar_stop_talking: Fired when avatar stops speaking
  • stream_ready: Fired when stream is ready with session data
  • stream_disconnected: Fired when stream disconnects
  • error: Fired when an error occurs
  • connection_established: Fired when WebRTC connection is established
  • session_created: Fired when session is created with session ID
  • websocket_connected: Fired when WebSocket connects
  • websocket_disconnected: Fired when WebSocket disconnects

Enhanced API Integration

This SDK integrates with your enhanced streaming API backend:

Authentication Flow

  1. Token Creation: POST /api/v1/streaming/create_token
  2. Session Creation: POST /api/v1/streaming/new
  3. WebSocket Connection: GET /ws/sdk/{session_id}

Real-time Communication

  • WebSocket: Real-time bidirectional communication
  • HTTP Fallback: API endpoints for speak/interrupt
  • Event System: Real-time status updates

Available Endpoints

  • POST /api/v1/streaming/create_token - Create auth token
  • POST /api/v1/streaming/new - Create session
  • POST /api/v1/streaming/start - Start session
  • DELETE /api/v1/streaming/end_session - End session
  • POST /api/v1/streaming/speak - Make avatar speak
  • POST /api/v1/streaming/interrupt - Interrupt speech
  • GET /api/v1/streaming/avatars - List available avatars
  • GET /api/v1/streaming/health - Health check

Backend Requirements

Make sure your LiveTalking server is running with the enhanced API:

python app.py --model wav2lip --transport webrtc --listenport 8010

The enhanced API will be available at: http://localhost:8010/api/v1/streaming/

Features

  • ✅ JWT-based authentication
  • ✅ WebSocket real-time communication
  • ✅ HTTP API fallback
  • ✅ Session management
  • ✅ Text-to-speech with Wav2Lip
  • ✅ Speech interruption
  • ✅ Event-driven architecture
  • ✅ TypeScript support
  • ✅ WebRTC integration ready
  • ✅ Keep-alive ping/pong
  • ✅ Error handling and recovery

License

Apache-2.0