Verbara.Sdk.VoiceAi.AudioSocket 2.6.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Verbara.Sdk.VoiceAi.AudioSocket --version 2.6.1
                    
NuGet\Install-Package Verbara.Sdk.VoiceAi.AudioSocket -Version 2.6.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Verbara.Sdk.VoiceAi.AudioSocket" Version="2.6.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Verbara.Sdk.VoiceAi.AudioSocket" Version="2.6.1" />
                    
Directory.Packages.props
<PackageReference Include="Verbara.Sdk.VoiceAi.AudioSocket" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Verbara.Sdk.VoiceAi.AudioSocket --version 2.6.1
                    
#r "nuget: Verbara.Sdk.VoiceAi.AudioSocket, 2.6.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Verbara.Sdk.VoiceAi.AudioSocket@2.6.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Verbara.Sdk.VoiceAi.AudioSocket&version=2.6.1
                    
Install as a Cake Addin
#tool nuget:?package=Verbara.Sdk.VoiceAi.AudioSocket&version=2.6.1
                    
Install as a Cake Tool

Verbara.Sdk.VoiceAi.AudioSocket

AudioSocket transport for Verbara.Sdk.VoiceAi — bridges Asterisk AudioSocket streams into the Voice AI pipeline.

Installation

dotnet add package Verbara.Sdk.VoiceAi.AudioSocket

Quick Start

// Register as a hosted service (DI lifecycle managed)
services.AddAudioSocketServer(opts =>
{
    opts.ListenAddress = "0.0.0.0";
    opts.Port = 9092;
    opts.MaxConcurrentSessions = 100;
});

// Handle sessions manually (without VoiceAi pipeline)
var server = app.Services.GetRequiredService<AudioSocketServer>();
server.OnSessionStarted += async session =>
{
    await foreach (var frame in session.ReadAudioAsync(ct))
    {
        // process 20 ms PCM16 frames from Asterisk
    }
    await session.WriteAudioAsync(responseAudio, ct);
};

Features

  • AudioSocketServer — IHostedService TCP server; accepts Asterisk AudioSocket connections
  • AudioSocketSession — per-call session with ReadAudioAsync() and WriteAudioAsync() for 20 ms PCM16 frames
  • UUID handshake: automatically reads the channel UUID frame from Asterisk on connection
  • OnSessionStarted event for routing sessions to custom handlers
  • AddAudioSocketServer() DI extension for one-line registration
  • Zero-copy System.IO.Pipelines framing; Native AOT compatible

A call that comes back with the same UUID

Asterisk does not keep the AudioSocket UUID unique. A dialplan that runs AudioSocket() or Dial(AudioSocket/…) again with the UUID it saved, a transfer, or a redirect that re-enters the bot connects again with the same UUID, often before the previous session has finished ending.

  • The call is served. The new connection waits for the previous session with that UUID to end, for at most 1 second, and is then served. OnSessionStarted is raised for it only after every OnHangup handler of the previous session has returned, so state you key by ChannelId never holds two live sessions under one UUID. Keep OnHangup handlers short: while they run, the session still holds its UUID and counts in ActiveSessionCount, and a handler that takes longer than the wait makes the call that comes back be refused.
  • A UUID still live after 1 second is refused. Two concurrent calls configured with one UUID are a dialplan error: the second connection receives a hangup frame, is closed, and the server logs the ChannelIdInUse Warning naming the UUID and how long it waited. The first call is untouched.
  • What the caller hears after a refusal. Every refusal, for a UUID in use or for MaxConcurrentSessions, writes a hangup frame before closing. On Asterisk 20 and later, AudioSocket() then returns and the dialplan goes on. On Asterisk 18 any end from the server, a hangup frame included, fails the application and the call is hung up.

Give every concurrent AudioSocket call its own UUID, for example Set(BOTID=${UUID()}) once per call, and reuse it only when the same call comes back to the bot.

Documentation

See the main README for full documentation.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Verbara.Sdk.VoiceAi.AudioSocket:

Package Downloads
Verbara.Sdk.VoiceAi

Voice AI pipeline for Verbara.Sdk — orchestration layer for STT, TTS and conversation with turn-taking and barge-in detection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.8.0 38 10/9/2026
2.7.0 766 10/3/2026
2.6.1 516 9/30/2026
2.6.0 746 9/24/2026
2.5.3 631 9/13/2026
2.5.2 302 9/13/2026
2.5.1 317 9/12/2026
2.5.0 386 8/25/2026
2.4.0 1,989 7/27/2026
2.3.2 682 7/20/2026
2.3.1 298 7/14/2026
2.3.0 437 7/6/2026
2.2.1 886 5/23/2026
2.2.0 198 5/20/2026
2.1.2 193 5/8/2026
2.1.1 184 5/7/2026
2.1.0 3,443 5/7/2026
2.0.0 173 5/6/2026