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

lm-avatar-chat-sdk

v1.1.0

Published

lm avatar chat web sdk

Readme

lm-avatar-chat-sdk

概述

灵眸数字人对话web端sdk,是一个实时流媒体数字人Web SDK(JavaScript 库),支持云端推流数字人和端到端渲染数字人,具备低延迟、高性能、高并发、跨平台等优势, 结合阿里云的RTC、语音交互、渲染引擎、脸部和肢体驱动等技术,提供多种数字人解决方案。

产品优势

● 高性能低延迟 ● 轻松集成、标准化输出 ● 多种数字人解决方案提供支持

产品能力

● 云端渲染数字人○ 云端渲染数字人是通过阿里云RTC提供视频流订阅,SDK在浏览器上拉取视频流呈现数字人的解决方案。○ 云端渲染数字人具备完整的语音交互、脸部和肢体驱动能力,提供数字人打断、多种对话模式。● 端侧渲染(端到端)数字人○ 端侧渲染数字人是通过阿里云RTC提供音频和模型脸部肢体动作数据,SDK在浏览器上通过拉取数据并使用WebGL渲染数字人的解决方案。○ 端侧渲染(端到端)数据人同样具备完整的语音交互、脸部和肢体驱动能力,同样提供数字人打断、多种对话模式。

快速开始

  1. 安装依赖
npm install lm-avatar-chat-sdk
  1. 设置挂载元素云端渲染数字人底层通过阿里云RTC进行音视频流的传输,需要挂载在一个video元素上。所以开发者要在页面html中先添加video容器元素。
<video id="cloudAvatarContainer" muted></video>
  1. 创建云端渲染数字人
import {
  createAvatar,
  TYAvatarType,
  IAvatarInitConfig,
  TYVoiceChatMessage,
  TYVoiceChatMessageType,
  TYVoiceChatState,
  TYVoiceChatMode,
} from 'lm-avatar-chat-sdk';

const avatarInitParams = {
    rootContainer: '#cloudAvatarContainer',
    ...
} as IAvatarInitConfig // 另外一些rtc参数从服务端接口获取并填入

const avatar = createAvatar(TYAvatarType.cloudAvatar, avatarInitParams)
  1. 启动对话
avatar.start({
  mode: TYVoiceChatMode.tap2talk,
})
  1. 绑定事件回调并不是所有回调都需要绑定,建议开发者根据业务开发需求进行绑定即可
avatar.onFirstFrameReceived(() => {
  console.log('数字人渲染完毕')
})

avatar.onReadyToSpeech(() => {
  console.log('可以进行语音交互了')
})

avatar.onErrorReceived((err: TYError) => {
  console.log('数字人内部发生错误:' + err.code + ' ' + err.message)
  if (err.terminate) {
    // 服务端已退出,在这里可以执行业务前端退出
  }
})

avatar.onStateChanged((tyState: TYVoiceChatState) => {
  console.log('当前数字人状态' + tyState)
})

avatar.onVolumeChanged((data: TYVolume) => {
  if (data.source === TYVolumeSourceType.mic) {
    console.log('用户音量:' + data.volume)
  } else {
    console.log('数字人音量:' + data.volume)
  }
})
avatar.onMessageReceived((msg: TYVoiceChatMessage) => {
  if (msg.type === TYVoiceChatMessageType.speaking) {
    console.log('用户的对话文本内容', msg.text)
  } else {
    console.log('数字人的反馈文本内容', msg.text)
  }
})
  1. 重要方法
// 暂停收音/恢复收音
avatar.muteLocalMic(mute: boolean)

// 打断
avatar.interrupt()

// 退出
avatar.exit()