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

@sonoba/voice-client

v0.5.2

Published

Voice Pipeline SDK — WebSocket, VAD, audio playback

Downloads

974

Readme

@sonoba/voice-client

npm license

日本語特化 Voice Pipeline の Core SDK。LiveKit WebRTC 接続・クライアントサイド VAD(Silero)・音声再生をワンパッケージで提供します。


インストール

npm install @sonoba/voice-client

クイックスタート

import { SonobaVoiceClient } from '@sonoba/voice-client';

const client = new SonobaVoiceClient({
  pipelineUrl: 'https://pipeline.example.com',
});

client.on('transcript:user', ({ text }) => console.log('あなた:', text));
// transcript:agent.text は **delta**(前回 emit からの差分)。表示時は streamId 単位で蓄積する。
client.on('transcript:agent', ({ text, isFinal, streamId }) => {
  console.log('AI delta:', text, isFinal ? '(final)' : '');
});
client.on('status:change', (status) => console.log('状態:', status));

await client.connect();

オプション

const client = new SonobaVoiceClient({
  pipelineUrl: 'https://pipeline.example.com',  // 必須: Pipeline Server の base URL

  // --- VAD(Silero ONNX、デフォルト ON) ---
  vad: true,
  vadModelUrl: '/silero_vad.onnx',
  vadOptions: {
    activationThreshold: 0.5,   // 平滑後 probability の閾値
    smoothingAlpha: 0.35,       // ExpFilter alpha、(0, 1]、低いほど平滑が強い
    minSpeechMs: 200,           // これより短い発話は drop(cough 除去)
    minSilenceMs: 600,          // この長さの無音で utterance 確定(日本語の間に最適化)
  },

  // --- バージイン ---
  autoBargeIn: true,            // TTS 再生中の発話で自動 bargeIn() を発火(デフォルト: true)
  bargeInThreshold: 300,        // 自動 barge-in までの持続発話 ms(デフォルト: 300)
  vadCancelThreshold: 250,      // これより短い発話は vad:cancel として扱う(デフォルト: 250)

  // --- コールバック(コンストラクタで登録) ---
  callbacks: {
    'status:change': (status) => console.log(status),
    'error': (err) => console.error(err),
  },
});

メソッド

| メソッド / プロパティ | 説明 | |---------|------| | connect(config?) | Pipeline Server からトークンを取得し LiveKit に接続。オプションで SessionConfig を渡せる | | disconnect() | 切断、VAD・リモートオーディオ等のリソース解放 | | setMuted(muted) | マイクのミュート切り替え | | isMuted() | 現在のミュート状態を返す | | sendText(text) | テキスト入力を text:input で送信 | | bargeIn() | audio:barge_in をサーバーに送信(割り込み)。エージェント非再生中は no-op | | setPipelineUrl(url) | 次回 connect() で使う Pipeline Server URL を更新 | | getSessionId() | 現在のセッション ID を返す(未接続時は null) | | playing | エージェントが TTS 再生中なら true(getter) | | status | 現在の ConnectionStatus(getter) |


イベント一覧

client.on('status:change', (status) => {});                // 接続状態の変化
client.on('session:ack', (data) => {});                    // session 受理(sessionId を含む)
client.on('transcript:user', ({ text }) => {});            // ユーザー発話の認識結果
client.on('transcript:agent', ({ text, isFinal, streamId }) => {}); // AI 返答 (delta)
client.on('audio:tts_start', (data) => {});                // TTS ストリーム開始(server 起点)
client.on('audio:tts_end', (data) => {});                  // TTS ストリーム終了(server 起点)
client.on('audio:playback_end', (data) => {});             // ローカル再生バッファ消化完了(audio:tts_end とは独立、順序不定)
client.on('audio:binary', (data) => {});                   // 生の音声フレーム(上級者向け)
client.on('vad:start', () => {});                          // 発話開始検出
client.on('vad:end', () => {});                            // 発話終了検出
client.on('vad:cancel', () => {});                         // 短すぎる発話を misfire として破棄
client.on('mic:muted', (muted) => {});                     // ミュート状態変化
client.on('error', (err) => {});                           // エラー
client.on('custom', ({ type, data }) => {});               // 未知の server message を passthrough

ライセンス

MIT © sonoba