Skip to content

Commit dfd42d2

Browse files
committed
Use AutoSDK CLI for docs sync
1 parent d0fb8dd commit dfd42d2

File tree

8 files changed

+176
-59
lines changed

8 files changed

+176
-59
lines changed

.github/workflows/mkdocs.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- 'docs/**'
88
- 'mkdocs.yml'
99
- 'examples/**'
10-
- 'src/helpers/GenerateDocs/**'
10+
- 'autosdk.docs.json'
1111
- '.github/workflows/mkdocs.yml'
1212
- 'src/tests/IntegrationTests/**'
1313
- 'README.md'
@@ -39,8 +39,11 @@ jobs:
3939
with:
4040
dotnet-version: 10.0.x
4141

42+
- name: Install AutoSDK CLI
43+
run: dotnet tool install --global autosdk.cli --prerelease
44+
4245
- name: Generate docs
43-
run: dotnet run --project src/helpers/GenerateDocs/GenerateDocs.csproj .
46+
run: autosdk docs sync .
4447

4548
- name: Build with MkDocs
4649
run: |

AssemblyAI.slnx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Solution>
22
<Folder Name="/helpers/">
3-
<Project Path="src/helpers/GenerateDocs/GenerateDocs.csproj" />
43
<Project Path="src/helpers/TrimmingHelper/TrimmingHelper.csproj" />
54
</Folder>
65
<Folder Name="/libs/">

docs/index.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# AssemblyAI
2+
3+
[![Nuget package](https://img.shields.io/nuget/vpre/tryAGI.AssemblyAI)](https://www.nuget.org/packages/tryAGI.AssemblyAI/)
4+
[![dotnet](https://github.com/tryAGI/AssemblyAI/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/tryAGI/AssemblyAI/actions/workflows/dotnet.yml)
5+
[![License: MIT](https://img.shields.io/github/license/tryAGI/AssemblyAI)](https://github.com/tryAGI/AssemblyAI/blob/main/LICENSE.txt)
6+
[![Discord](https://img.shields.io/discord/1115206893015662663?label=Discord&logo=discord&logoColor=white&color=d82679)](https://discord.gg/Ca2xhfBf3v)
7+
8+
AssemblyAI has [an official .NET SDK](https://github.com/AssemblyAI/assemblyai-csharp-sdk) available,
9+
and we use this SDK primarily to improve the overall experience
10+
of our SDK/try to reach/exceed the level of the official one and
11+
extend it to all our generated SDKs for other platforms.
12+
13+
## Features 🔥
14+
- Fully generated C# SDK based on [official AssemblyAI OpenAPI specification](https://raw.githubusercontent.com/AssemblyAI/assemblyai-api-spec/main/openapi.yml) using [OpenApiGenerator](https://github.com/HavenDV/OpenApiGenerator)
15+
- Same day update to support new features
16+
- Updated and supported automatically if there are no breaking changes
17+
- All modern .NET features - nullability, trimming, NativeAOT, etc.
18+
- Support .Net Framework/.Net Standard 2.0
19+
20+
### Usage
21+
```csharp
22+
using AssemblyAI;
23+
24+
using var api = new AssemblyAIClient(apiKey);
25+
26+
var fileUrl = "https://github.com/AssemblyAI-Community/audio-examples/raw/main/20230607_me_canadian_wildfires.mp3";
27+
28+
//// You can also transcribe a local file by passing in a file path
29+
// var filePath = "./path/to/file.mp3";
30+
// var uploadedFile = await client.Transcript.UploadFileAsync();
31+
// fileUrl = uploadedFile.UploadUrl;
32+
33+
Transcript transcript = await client.Transcript.CreateTranscriptAsync(TranscriptParams.FromUrl(
34+
fileUrl,
35+
new TranscriptOptionalParams
36+
{
37+
LanguageDetection = true,
38+
SpeakerLabels = true, // Identify speakers in your audios
39+
AutoHighlights = true, // Identifying highlights in your audio
40+
}));
41+
42+
transcript.EnsureStatusCompleted();
43+
44+
Console.WriteLine(transcript);
45+
```
46+
47+
## Support
48+
49+
Priority place for bugs: https://github.com/tryAGI/AssemblyAI/issues
50+
Priority place for ideas and general questions: https://github.com/tryAGI/AssemblyAI/discussions
51+
Discord: https://discord.gg/Ca2xhfBf3v
52+
53+
## Acknowledgments
54+
55+
![JetBrains logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png)
56+
57+
This project is supported by JetBrains through the [Open Source Support Program](https://jb.gg/OpenSourceSupport).
58+
59+
![CodeRabbit logo](https://opengraph.githubassets.com/1c51002d7d0bbe0c4fd72ff8f2e58192702f73a7037102f77e4dbb98ac00ea8f/marketplace/coderabbitai)
60+
61+
This project is supported by CodeRabbit through the [Open Source Support Program](https://github.com/marketplace/coderabbitai).

docs/samples/Transcribe.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
```csharp
2+
using var client = GetAuthenticatedApi();
3+
4+
var fileUrl = "https://github.com/AssemblyAI-Community/audio-examples/raw/main/20230607_me_canadian_wildfires.mp3";
5+
6+
// You can also transcribe a local file by passing in a file path
7+
// var filePath = "./path/to/file.mp3";
8+
// var uploadedFile = await client.Transcript.UploadFileAsync();
9+
// fileUrl = uploadedFile.UploadUrl;
10+
11+
Transcript transcript = await client.Transcript.CreateTranscriptAsync(TranscriptParams.FromUrl(
12+
fileUrl,
13+
new TranscriptOptionalParams
14+
{
15+
SpeechModels = [],
16+
LanguageDetection = true,
17+
SpeakerLabels = true, // Identify speakers in your audios
18+
AutoHighlights = true, // Identifying highlights in your audio
19+
}));
20+
21+
transcript.EnsureStatusCompleted();
22+
23+
Console.WriteLine(transcript);
24+
25+
// If you want to summarize the transcript, you can use the Lemur API
26+
// LemurTaskResponse response = await client.LeMUR.LemurTaskAsync(LemurTaskParams.FromPrompt(
27+
// prompt: "Provide a brief summary of the transcript.",
28+
// @params: new LemurBaseParams
29+
// {
30+
// TranscriptIds = [transcript.Id],
31+
// FinalModel = LemurModel.AnthropicClaude35Sonnet
32+
// }));
33+
//
34+
// Console.WriteLine(response.String?.Value1?.Response ?? "No response found.");
35+
// Console.WriteLine($"Input tokens: {response.String?.Value2?.Usage.InputTokens}");
36+
// Console.WriteLine($"Input tokens: {response.String?.Value2?.Usage.OutputTokens}");
37+
```

docs/samples/TranscribeLive.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
```csharp
2+
using var client = GetAuthenticatedApi();
3+
4+
// - You need to have `sox` installed on your system. If not, run:
5+
// macOS: brew install sox (macOS)
6+
// Linux: sudo apt-get install sox libsox-fmt-all
7+
// Windows: manually download and install sox, and add sox to your PATH environment variable.
8+
// https://sourceforge.net/projects/sox/
9+
10+
// Set up the cancellation token, so we can stop the program with Ctrl+C
11+
var cts = new CancellationTokenSource();
12+
var ct = cts.Token;
13+
Console.CancelKeyPress += (sender, e) => cts.Cancel();
14+
15+
// Set up the realtime transcriber
16+
// await using var transcriber = new RealtimeTranscriber(new RealtimeTranscriberOptions
17+
// {
18+
// SampleRate = 16_000
19+
// });
20+
//
21+
// transcriber.PartialTranscriptReceived.Subscribe(transcript =>
22+
// {
23+
// if (transcript.Text == "") return;
24+
// Console.WriteLine($"Partial transcript: {transcript.Text}");
25+
// });
26+
// transcriber.FinalTranscriptReceived.Subscribe(transcript =>
27+
// {
28+
// Console.WriteLine($"Final transcript: {transcript.Text}");
29+
// });
30+
31+
//await transcriber.ConnectAsync();
32+
33+
var soxArguments = string.Join(' ', [
34+
// --default-device doesn't work on Windows
35+
OperatingSystem.IsWindows() ? "-t waveaudio default" : "--default-device",
36+
"--no-show-progress",
37+
"--rate 16000",
38+
"--channels 1",
39+
"--encoding signed-integer",
40+
"--bits 16",
41+
"--type wav",
42+
"-" // pipe
43+
]);
44+
Console.WriteLine($"sox {soxArguments}");
45+
using var soxProcess = new Process();
46+
soxProcess.StartInfo = new ProcessStartInfo
47+
{
48+
FileName = "sox",
49+
Arguments = soxArguments,
50+
RedirectStandardOutput = true,
51+
RedirectStandardError = true,
52+
UseShellExecute = false,
53+
CreateNoWindow = true
54+
};
55+
56+
soxProcess.Start();
57+
soxProcess.BeginErrorReadLine();
58+
var soxOutputStream = soxProcess.StandardOutput.BaseStream;
59+
var buffer = new Memory<byte>(new byte[4096]);
60+
while (await soxOutputStream.ReadAsync(buffer, ct) > 0)
61+
{
62+
if (ct.IsCancellationRequested) break;
63+
//await transcriber.SendAudioAsync(buffer);
64+
}
65+
66+
soxProcess.Kill();
67+
//await transcriber.CloseAsync();
68+
```

mkdocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
site_name: AssemblyAI .NET Documentation
22
nav:
33
- Overview: index.md
4-
# EXAMPLES #
4+
# EXAMPLES:START
5+
- Examples:
6+
- Transcribe: samples/Transcribe.md
7+
- TranscribeLive: samples/TranscribeLive.md
8+
# EXAMPLES:END
59

610
theme:
711
name: material

src/helpers/GenerateDocs/GenerateDocs.csproj

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/helpers/GenerateDocs/Program.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)