AssemblyAI.SemanticKernel 1.0.2-alpha

This is a prerelease version of AssemblyAI.SemanticKernel.
There is a newer version of this package available.
See the version list below for details.
dotnet add package AssemblyAI.SemanticKernel --version 1.0.2-alpha                
NuGet\Install-Package AssemblyAI.SemanticKernel -Version 1.0.2-alpha                
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.0.2-alpha" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AssemblyAI.SemanticKernel --version 1.0.2-alpha                
#r "nuget: AssemblyAI.SemanticKernel, 1.0.2-alpha"                
#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.0.2-alpha&prerelease

// Install AssemblyAI.SemanticKernel as a Cake Tool
#tool nuget:?package=AssemblyAI.SemanticKernel&version=1.0.2-alpha&prerelease                

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


GitHub License CI Build AssemblyAI Twitter AssemblyAI YouTube

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 TranscriptPlugin into your kernel:

using AssemblyAI.SemanticKernel;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Orchestration;

// Build your kernel
var kernel = new KernelBuilder().Build();

// 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.");

var transcriptPlugin = kernel.ImportSkill(
    new TranscriptPlugin(apiKey: apiKey),
    TranscriptPlugin.PluginName
);

Usage

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

var function = kernel.Skills
    .GetFunction(TranscriptPlugin.PluginName, TranscriptPlugin.TranscribeFunctionName);
var context = kernel.CreateNewContext();
context.Variables["audioUrl"] = "https://storage.googleapis.com/aai-docs-samples/espn.m4a";
await function.InvokeAsync(context);
Console.WriteLine(context.Result);

The context.Result property contains the transcript text if successful.

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

  • Set the TranscriptPlugin.AllowFileSystemAccess property to true
  • Configure the path of the file to upload as the filePath parameter
var transcriptPlugin = kernel.ImportSkill(
    new TranscriptPlugin(apiKey: apiKey)
    {
        AllowFileSystemAccess = true
    },
    TranscriptPlugin.PluginName
);
var function = kernel.Skills
    .GetFunction(TranscriptPlugin.PluginName, TranscriptPlugin.TranscribeFunctionName);
var context = kernel.CreateNewContext();
context.Variables["filePath"] = "./espn.m4a";
await function.InvokeAsync(context);
Console.WriteLine(context.Result);

If filePath and audioUrl are specified, the filePath will be used to upload the file and audioUrl will be overridden.

Lastly, you can also use the INPUT variable, so you can transcribe a file like this.

var function = kernel.Skills
    .GetFunction(TranscriptPlugin.PluginName, TranscriptPlugin.TranscribeFunctionName);
var context = await function.InvokeAsync("./espn.m4a");

Or from within a semantic function like this.

var prompt = """
             Here is a transcript:
             {{TranscriptPlugin.Transcribe "https://storage.googleapis.com/aai-docs-samples/espn.m4a"}}
             ---
             Summarize the transcript.
             """;
var context = kernel.CreateNewContext();
var function = kernel.CreateSemanticFunction(prompt);
await function.InvokeAsync(context);
Console.WriteLine(context.Result);

If the INPUT variable is a URL, it'll be used as the audioUrl, otherwise, it'll be used as the filePath. If either audioUrl or filePath are configured, INPUT is ignored.

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!
  • Semantic Kernel itself is still in pre-release, and changes frequently, so we'll keep our integration in pre-release until SK is GA'd.
  • 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 165 8/14/2024
1.1.1 122 7/16/2024
1.1.0 704 2/17/2024
1.0.3 257 12/20/2023
1.0.2-alpha 168 10/2/2023
1.0.1-alpha 165 9/26/2023
1.0.0-alpha 119 9/20/2023