{"id":26359109,"url":"https://github.com/assemblyai/assemblyai-csharp-sdk","last_synced_at":"2025-03-16T15:58:44.780Z","repository":{"id":219172341,"uuid":"707823874","full_name":"AssemblyAI/assemblyai-csharp-sdk","owner":"AssemblyAI","description":"The AssemblyAI C# .NET SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, audio intelligence models, as well as the latest LeMUR models.","archived":false,"fork":false,"pushed_at":"2025-02-05T09:49:30.000Z","size":7289,"stargazers_count":8,"open_issues_count":4,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-07T14:38:32.889Z","etag":null,"topics":["ai","asr","assemblyai","csharp","dotnet","llm","speech-to-text"],"latest_commit_sha":null,"homepage":"https://www.assemblyai.com","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AssemblyAI.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-20T18:36:00.000Z","updated_at":"2025-02-26T18:20:46.000Z","dependencies_parsed_at":"2024-09-06T06:11:53.915Z","dependency_job_id":"353662a6-9be5-4101-a0a3-a70d4aeda440","html_url":"https://github.com/AssemblyAI/assemblyai-csharp-sdk","commit_stats":null,"previous_names":["assemblyai/assemblyai-csharp-sdk"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI%2Fassemblyai-csharp-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI%2Fassemblyai-csharp-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI%2Fassemblyai-csharp-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AssemblyAI%2Fassemblyai-csharp-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AssemblyAI","download_url":"https://codeload.github.com/AssemblyAI/assemblyai-csharp-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243893860,"owners_count":20364916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","asr","assemblyai","csharp","dotnet","llm","speech-to-text"],"created_at":"2025-03-16T15:58:44.710Z","updated_at":"2025-03-16T15:58:44.771Z","avatar_url":"https://github.com/AssemblyAI.png","language":"C#","readme":"\u003cimg src=\"https://github.com/AssemblyAI/assemblyai-python-sdk/blob/master/assemblyai.png?raw=true\" width=\"500\" alt=\"AssemblyAI logo\"/\u003e\n\n---\n\n# AssemblyAI C# .NET SDK\n\n[![NuGet](https://img.shields.io/nuget/v/AssemblyAI.svg)](https://www.nuget.org/packages/AssemblyAI)\n[![GitHub License](https://img.shields.io/github/license/AssemblyAI/assemblyai-csharp-sdk)](https://github.com/AssemblyAI/assemblyai-csharp-sdk/blob/main/LICENSE)\n[![AssemblyAI Twitter](https://img.shields.io/twitter/follow/AssemblyAI?label=%40AssemblyAI\u0026style=social)](https://twitter.com/AssemblyAI)\n[![AssemblyAI YouTube](https://img.shields.io/youtube/channel/subscribers/UCtatfZMf-8EkIwASXM4ts0A)](https://www.youtube.com/@AssemblyAI)\n[![Discord](https://img.shields.io/discord/875120158014853141?logo=discord\u0026label=Discord\u0026link=https%3A%2F%2Fdiscord.com%2Fchannels%2F875120158014853141\u0026style=social)\n](https://assembly.ai/discord)\n\nThe AssemblyAI C# SDK provides an easy-to-use interface for interacting with the AssemblyAI API from .NET, which supports async and real-time transcription, as well as the latest audio intelligence and LeMUR models.\nThe C# SDK is compatible with `.NET 6.0` and up, `.NET Framework 4.6.2` and up, and `.NET Standard 2.0`.\n\n## Documentation\n\nVisit the [AssemblyAI documentation](https://www.assemblyai.com/docs) for step-by-step instructions and a lot more details about our AI models and API.\nExplore [the SDK API reference](https://assemblyai.github.io/assemblyai-csharp-sdk/) for more details on the SDK types, functions, and classes.\n\n## Quickstart\n\nYou can find the `AssemblyAI` C# SDK on [NuGet](https://www.nuget.org/packages/AssemblyAI).\nAdd the latest version using the .NET CLI:\n\n```bash\ndotnet add package AssemblyAI\n```\n\nThen, create an AssemblyAIClient with your API key:\n\n```csharp\nusing AssemblyAI;\n\nvar client = new AssemblyAIClient(Environment.GetEnvironmentVariable(\"ASSEMBLYAI_API_KEY\")!);\n```\n\nYou can now use the `client` object to interact with the AssemblyAI API.\n\n## Add the AssemblyAIClient to the dependency injection container\n\nThe AssemblyAI SDK has built-in support for default .NET dependency injection container.\nAdd the `AssemblyAIClient` to the service collection like this:\n\n```csharp\nusing AssemblyAI;\n\n// build your services\nservices.AddAssemblyAIClient();\n\n```\n\nBy default, the `AssemblyAIClient` loads it configuration from the `AssemblyAI` section from the .NET configuration.\n\n```json\n{\n  \"AssemblyAI\": {\n    \"ApiKey\": \"YOUR_ASSEMBLYAI_API_KEY\"\n  }\n}\n```\n\nYou can also configure the `AssemblyAIClient` other ways using the `AddAssemblyAIClient` overloads.\n\n```csharp\nusing AssemblyAI;\n\n// build your services\nservices.AddAssemblyAIClient(options =\u003e\n{\n    options.ApiKey = Environment.GetEnvironmentVariable(\"ASSEMBLYAI_API_KEY\")!;\n});\n```\n\n## Speech-To-Text\n\n### Transcribe audio and video files\n\n\u003cdetails open\u003e\n  \u003csummary\u003eTranscribe an audio file with a public URL\u003c/summary\u003e\n\nWhen you create a transcript, you can either pass in a URL to an audio file or upload a file directly.\n\n```csharp\nusing AssemblyAI;\nusing AssemblyAI.Transcripts;\n\nvar client = new AssemblyAIClient(Environment.GetEnvironmentVariable(\"ASSEMBLYAI_API_KEY\")!);\n\n// Transcribe file at remote URL\nvar transcript = await client.Transcripts.TranscribeAsync(new TranscriptParams\n{\n    AudioUrl = \"https://assembly.ai/espn.m4a\",\n    LanguageCode = TranscriptLanguageCode.EnUs\n});\n\n// checks if transcript.Status == TranscriptStatus.Completed, throws an exception if not\ntranscript.EnsureStatusCompleted();\n\nConsole.WriteLine(transcript.Text);\n```\n\n`TranscribeAsync` queues a transcription job and polls it until the `transcript.Status` is `completed` or `error`.\n\nIf you don't want to wait until the transcript is ready, you can use `submit`:\n\n```csharp\ntranscript = await client.Transcripts.SubmitAsync(new TranscriptParams\n{\n    AudioUrl = \"https://assembly.ai/espn.m4a\",\n    LanguageCode = TranscriptLanguageCode.EnUs\n});\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eTranscribe a local audio file\u003c/summary\u003e\n\nWhen you create a transcript, you can either pass in a URL to an audio file or upload a file directly.\n\n```csharp\nusing AssemblyAI;\nusing AssemblyAI.Transcripts;\n\nvar client = new AssemblyAIClient(Environment.GetEnvironmentVariable(\"ASSEMBLYAI_API_KEY\")!);\n\n// Transcribe file using file info\nvar transcript = await client.Transcripts.TranscribeAsync(\n    new FileInfo(\"./news.mp4\"),\n    new TranscriptOptionalParams\n    {\n        LanguageCode = TranscriptLanguageCode.EnUs\n    }\n);\n\n// Transcribe file from stream\nawait using var stream = new FileStream(\"./news.mp4\", FileMode.Open);\ntranscript = await client.Transcripts.TranscribeAsync(\n    stream,\n    new TranscriptOptionalParams\n    {\n        LanguageCode = TranscriptLanguageCode.EnUs\n    }\n);\n```\n\n`transcribe` queues a transcription job and polls it until the `status` is `completed` or `error`.\n\nIf you don't want to wait until the transcript is ready, you can use `submit`:\n\n```csharp\ntranscript = await client.Transcripts.SubmitAsync(\n    new FileInfo(\"./news.mp4\"),\n    new TranscriptOptionalParams\n    {\n        LanguageCode = TranscriptLanguageCode.EnUs\n    }\n);\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eEnable additional AI models\u003c/summary\u003e\n\nYou can extract even more insights from the audio by enabling any of our [AI models](https://www.assemblyai.com/docs/audio-intelligence) using _transcription options_.\nFor example, here's how to enable [Speaker diarization](https://www.assemblyai.com/docs/speech-to-text/speaker-diarization) model to detect who said what.\n\n```csharp\nvar transcript = await client.Transcripts.TranscribeAsync(new TranscriptParams\n{\n    AudioUrl = \"https://assembly.ai/espn.m4a\",\n    SpeakerLabels = true\n});\n\n// checks if transcript.Status == TranscriptStatus.Completed, throws an exception if not\ntranscript.EnsureStatusCompleted();\n\nforeach (var utterance in transcript.Utterances)\n{\n    Console.WriteLine($\"Speaker {utterance.Speaker}: {utterance.Text}\");\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGet a transcript\u003c/summary\u003e\n\nThis will return the transcript object in its current state. If the transcript is still processing, the `Status` field will be `Queued` or `Processing`. Once the transcript is complete, the `Status` field will be `Completed`.\n\n```csharp\nvar transcript = await client.Transcripts.GetAsync(transcript.Id);\n```\n\nIf you created a transcript using `.SubmitAsync(...)`, you can still poll until the transcript `Status` is `Completed` or `Error` using `.WaitUntilReady(...)`:\n\n```csharp\ntranscript = await client.Transcripts.WaitUntilReady(\n    transcript.Id,\n    pollingInterval: TimeSpan.FromSeconds(1),\n    pollingTimeout: TimeSpan.FromMinutes(10)\n);\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eGet sentences and paragraphs\u003c/summary\u003e\n\n```csharp\nvar sentences = await client.Transcripts.GetSentencesAsync(transcript.Id);\nvar paragraphs = await client.Transcripts.GetParagraphsAsync(transcript.Id);\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eGet subtitles\u003c/summary\u003e\n\n```csharp\nconst int charsPerCaption = 32;\nvar srt = await client.Transcripts.GetSubtitlesAsync(transcript.Id, SubtitleFormat.Srt);\nsrt = await client.Transcripts.GetSubtitlesAsync(transcript.Id, SubtitleFormat.Srt, charsPerCaption: charsPerCaption);\n\nvar vtt = await client.Transcripts.GetSubtitlesAsync(transcript.Id, SubtitleFormat.Vtt);\nvtt = await client.Transcripts.GetSubtitlesAsync(transcript.Id, SubtitleFormat.Vtt, charsPerCaption: charsPerCaption);\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eList transcripts\u003c/summary\u003e\n\nThis will return a page of transcripts you created.\n\n```csharp\nvar page = await client.Transcripts.ListAsync();\n```\n\nYou can also paginate over all pages.\n\n```csharp\nvar page = await client.Transcripts.ListAsync();\nwhile(page.PageDetails.PrevUrl != null)\n{\n    page = await client.Transcripts.ListAsync(page.PageDetails.PrevUrl);\n}\n```\n\n\u003e [!NOTE]\n\u003e To paginate over all pages, you need to use the `page.PageDetails.PrevUrl`\n\u003e because the transcripts are returned in descending order by creation date and time.\n\u003e The first page is are the most recent transcript, and each \"previous\" page are older transcripts.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eDelete a transcript\u003c/summary\u003e\n\n```csharp\nvar transcript = await client.Transcripts.DeleteAsync(transcript.Id);\n```\n\n\u003c/details\u003e\n\n### Transcribe in real-time\n\nCreate the real-time transcriber.\n\n```csharp\nusing AssemblyAI;\nusing AssemblyAI.Realtime;\n\nvar client = new AssemblyAIClient(Environment.GetEnvironmentVariable(\"ASSEMBLYAI_API_KEY\")!);\nawait using var transcriber = client.Realtime.CreateTranscriber();\n```\n\nYou can also pass in the following options.\n\n```csharp\nusing AssemblyAI;\nusing AssemblyAI.Realtime;\n\nawait using var transcriber = client.Realtime.CreateTranscriber(new RealtimeTranscriberOptions\n{\n    // If ApiKey is null, the API key passed to `AssemblyAIClient` will be\n    ApiKey: Environment.GetEnvironmentVariable(\"ASSEMBLYAI_API_KEY\"),\n    RealtimeUrl = \"wss://localhost/override\",\n    SampleRate = 16_000,\n    WordBoost = new[] { \"foo\", \"bar\" }\n});\n```\n\n\u003e [!WARNING]\n\u003e Storing your API key in client-facing applications exposes your API key.\n\u003e Generate a temporary auth token on the server and pass it to your client.\n\u003e _Server code_:\n\u003e\n\u003e ```csharp\n\u003e var token = await client.Realtime.CreateTemporaryTokenAsync(expiresIn: 60);\n\u003e // TODO: return token to client\n\u003e ```\n\u003e\n\u003e _Client code_:\n\u003e\n\u003e ```csharp\n\u003e using AssemblyAI;\n\u003e using AssemblyAI.Realtime;\n\u003e\n\u003e var token = await GetToken();\n\u003e await using var transcriber = new RealtimeTranscriber {\n\u003e    Token = token.Token\n\u003e };\n\u003e ```\n\nYou can configure the following events.\n\n```csharp\ntranscriber.SessionBegins.Subscribe(\n    message =\u003e Console.WriteLine(\n        $\"\"\"\n         Session begins:\n         - Session ID: {message.SessionId}\n         - Expires at: {message.ExpiresAt}\n         \"\"\")\n);\n\ntranscriber.PartialTranscriptReceived.Subscribe(\n    transcript =\u003e Console.WriteLine(\"Partial transcript: {0}\", transcript.Text)\n);\n\ntranscriber.FinalTranscriptReceived.Subscribe(\n    transcript =\u003e Console.WriteLine(\"Final transcript: {0}\", transcript.Text)\n);\n\ntranscriber.TranscriptReceived.Subscribe(\n    transcript =\u003e Console.WriteLine(\"Transcript: {0}\", transcript.Match(\n        partialTranscript =\u003e partialTranscript.Text,\n        finalTranscript =\u003e finalTranscript.Text\n    ))\n);\n\ntranscriber.ErrorReceived.Subscribe(\n    error =\u003e Console.WriteLine(\"Error: {0}\", error)\n);\ntranscriber.Closed.Subscribe(\n    closeEvt =\u003e Console.WriteLine(\"Closed: {0} - {1}\", closeEvt.Code, closeEvt.Reason)\n);\n```\n\nAfter configuring your events, connect to the server.\n```csharp\nawait transcriber.ConnectAsync();\n```\n\nSend audio data via chunks.\n\n```csharp\n// Pseudo code for getting audio\nGetAudio(audioChunk =\u003e {\n    transcriber.SendAudio(audioChunk);\n});\n```\n\nClose the connection when you're finished.\n\n```csharp\nawait transcriber.CloseAsync();\n```\n\n## Apply LLMs to your audio with LeMUR\n\nCall [LeMUR endpoints](https://www.assemblyai.com/docs/api-reference/lemur) to apply LLMs to your transcript.\n\n\u003cdetails open\u003e\n\u003csummary\u003ePrompt your audio with LeMUR\u003c/summary\u003e\n\n```csharp\nvar response = await client.Lemur.TaskAsync(new LemurTaskParams\n{\n    TranscriptIds = [\"0d295578-8c75-421a-885a-2c487f188927\"],\n    Prompt = \"Write a haiku about this conversation.\",\n});\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSummarize with LeMUR\u003c/summary\u003e\n\n```csharp\nvar response = await client.Lemur.SummaryAsync(new LemurSummaryParams\n{\n    TranscriptIds = [\"0d295578-8c75-421a-885a-2c487f188927\"],\n    AnswerFormat = \"one sentence\",\n    Context = new Dictionary\u003cstring, object?\u003e\n    {\n        [\"Speaker\"] = new[] { \"Alex\", \"Bob\" }\n    }\n});\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eAsk questions\u003c/summary\u003e\n\n```csharp\nvar response = await client.Lemur.QuestionAnswerAsync(new LemurQuestionAnswerParams\n{\n    TranscriptIds =  [\"0d295578-8c75-421a-885a-2c487f188927\"],\n    Questions = [\n        new LemurQuestion\n        {\n            Question = \"What are they discussing?\",\n            AnswerFormat = \"text\"\n        }\n    ]\n});\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eGenerate action items\u003c/summary\u003e\n\n```csharp\nvar response = await client.Lemur.ActionItemsAsync(new LemurActionItemsParams\n{\n    TranscriptIds = [\"0d295578-8c75-421a-885a-2c487f188927\"]\n});\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003eDelete LeMUR request\u003c/summary\u003e\n\n```csharp\nvar response = await client.Lemur.PurgeRequestDataAsync(lemurResponse.RequestId);\n```\n\n\u003c/details\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemblyai%2Fassemblyai-csharp-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassemblyai%2Fassemblyai-csharp-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassemblyai%2Fassemblyai-csharp-sdk/lists"}