AssemblyAI.SemanticKernel 1.1.2

dotnet add package AssemblyAI.SemanticKernel --version 1.1.2                
NuGet\Install-Package AssemblyAI.SemanticKernel -Version 1.1.2                
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="AssemblyAI.SemanticKernel" Version="1.1.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AssemblyAI.SemanticKernel --version 1.1.2                
#r "nuget: AssemblyAI.SemanticKernel, 1.1.2"                
#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.
// Install AssemblyAI.SemanticKernel as a Cake Addin
#addin nuget:?package=AssemblyAI.SemanticKernel&version=1.1.2

// Install AssemblyAI.SemanticKernel as a Cake Tool
#tool nuget:?package=AssemblyAI.SemanticKernel&version=1.1.2                

<img src="https://github.com/AssemblyAI/assemblyai-python-sdk/blob/master/assemblyai.png?raw=true" width="500" alt="AssemblyAI logo"/>


Nuget (with prereleases) CI Build GitHub License AssemblyAI Twitter AssemblyAI YouTube Discord

AssemblyAI integration for Semantic Kernel

Transcribe audio using AssemblyAI with Semantic Kernel plugins.

Get started

Add the AssemblyAI.SemanticKernel NuGet package to your project.

dotnet add package AssemblyAI.SemanticKernel

Next, register the AssemblyAI plugin into your kernel:

using AssemblyAI.SemanticKernel;
using Microsoft.SemanticKernel;

// Build your kernel
var kernelBuilder = Kernel.CreateBuilder();

// add services like LLMs etc.

// Get AssemblyAI API key from env variables, or much better, from .NET configuration
string apiKey = Environment.GetEnvironmentVariable("ASSEMBLYAI_API_KEY")
  ?? throw new Exception("ASSEMBLYAI_API_KEY env variable not configured.");
kernelBuilder.AddAssemblyAIPlugin(new AssemblyAIPluginOptions
    {
        ApiKey = apiKey,
        PluginName = null,
        AllowFileSystemAccess = false
    });

var kernel = kernelBuilder.Build();

You can configure three options:

  • ApiKey: Configure the AssemblyAI API key
  • PluginName: Configure the name of the plugin inside of Semantic Kernel. Defaults to "AssemblyAIPlugin".
  • AllowFileSystemAccess: Allow the plugin to read files from the file system to upload audio files for transcriptions. Defaults to false.

kernelBuilder.AddAssemblyAIPlugin has overloads to configure the plugin using configuration and through a lambda.

Usage

Get the Transcribe function from the transcript plugin and invoke it with the context variables.

var result = await kernel.InvokeAsync<string>(
    nameof(AssemblyAIPlugin),
    AssemblyAIPlugin.TranscribeFunctionName,
    new KernelArguments
    {
        ["INPUT"] = "https://storage.googleapis.com/aai-docs-samples/espn.m4a"
    }
);
Console.WriteLine(result);

You can also upload local audio and video file. To do this:

  • Set the AssemblyAIPluginOptions.AllowFileSystemAccess to true.
  • Configure the INPUT variable with a local file path.
kernelBuilder.AddAssemblyAIPlugin(new AssemblyAIPluginOptions
    {
        ApiKey = apiKey,
        AllowFileSystemAccess = true
    });

...

var result = await kernel.InvokeAsync<string>(
    nameof(AssemblyAIPlugin), 
    AssemblyAIPlugin.TranscribeFunctionName, 
    new KernelArguments
    {
        ["INPUT"] = "./espn.m4a"
    }
);
Console.WriteLine(result);

You can also invoke the function from within a semantic function like this.

const string prompt = """
                      Here is a transcript:
                      {{AssemblyAIPlugin.Transcribe "https://storage.googleapis.com/aai-docs-samples/espn.m4a"}}
                      ---
                      Summarize the transcript.
                      """;
var result = await kernel.InvokePromptAsync<string>(prompt);
Console.WriteLine(result);

All the code above explicitly invokes the transcript plugin, but it can also be invoked as part of a plan. Check out the Sample project) which uses a plan to transcribe an audio file in addition to explicit invocation.

Notes

  • The AssemblyAI integration only supports Semantic Kernel with .NET at this moment. If there's demand, we will extend support to other platforms, so let us know!
  • Feel free to file an issue in case of bugs or feature requests.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 162 8/14/2024
1.1.1 121 7/16/2024
1.1.0 544 2/17/2024
1.0.3 254 12/20/2023
1.0.2-alpha 165 10/2/2023
1.0.1-alpha 164 9/26/2023
1.0.0-alpha 118 9/20/2023