Skip to content

Commit 647d0eb

Browse files
committed
Version 0.1.9
1 parent df7a48a commit 647d0eb

File tree

33 files changed

+476
-87
lines changed

33 files changed

+476
-87
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.1.7</Version>
3+
<Version>0.1.9</Version>
44
<Company>TensorStack</Company>
55
<Copyright>TensorStack - 2025</Copyright>
66
<RepositoryUrl>https://github.com/TensorStack-AI/TensorStack</RepositoryUrl>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# TensorStack.Audio.Windows
2+
`TensorStack.Audio.Windows` provides Windows-specific support for reading and writing audio using FFmpeg. It allows loading audio information, reading and writing audio tensors, and muxing audio into video files.
3+
4+
---
5+
6+
## AudioInput
7+
`AudioInput` wraps an audio file into a convenient object backed by an `AudioTensor`. It allows loading, manipulating, and saving audio.
8+
9+
```csharp
10+
// Load Audio
11+
12+
AudioInput audioInput = new AudioInput("speech.wav");
13+
14+
AudioInput audioInputAsync = await AudioInput.CreateAsync("speech.wav");
15+
16+
17+
// With custom codec, sample rate, and channels
18+
19+
AudioInput audioInput = new AudioInput("music.mp3", "pcm_f32le", 44100, 2);
20+
21+
AudioInput audioInputAsync = await AudioInput.CreateAsync("music.mp3", "pcm_f32le", 44100, 2);
22+
23+
24+
// Save Audio
25+
26+
audioInput.Save("output.wav");
27+
28+
await audioInput.SaveAsync("output.wav");
29+
```
30+
31+
32+
33+
## Notes
34+
35+
* `AudioInput` uses `AudioManager` internally to handle the audio tensor.
36+
* `AudioManager.Initialize` only needed for custom FFmpeg/FFprobe binaries or a different temp directory; the NuGet package provides defaults.
37+
38+
---
39+
40+
# AudioManager
41+
`AudioManager` is a static helper class for loading, saving, and processing audio files. It can read audio into tensors, write tensors back to audio files, extract audio from videos, and add audio to videos. It uses FFmpeg/FFprobe under the hood and provides both synchronous and asynchronous methods.
42+
43+
## Load Audio Information
44+
```csharp
45+
AudioInfo info = AudioManager.LoadInfo("file.wav");
46+
47+
AudioInfo info = await AudioManager.LoadInfoAsync("file.wav");
48+
```
49+
50+
Returns metadata including codec, sample rate, channels, duration, and sample count.
51+
52+
---
53+
54+
## Load Audio Tensor
55+
```csharp
56+
AudioTensor tensor = AudioManager.LoadTensor("file.wav", "pcm_s16le", 16000, 1);
57+
58+
AudioTensor tensor = await AudioManager.LoadTensorAsync("file.wav", "pcm_s16le", 16000, 1);
59+
```
60+
61+
`AudioTensor` contains the raw audio samples in float32 format.
62+
63+
---
64+
65+
## Save Audio Tensor
66+
```csharp
67+
AudioManager.SaveAudio("output.wav", tensor);
68+
69+
await AudioManager.SaveAudioAync("output.wav", tensor);
70+
```
71+
72+
---
73+
74+
## Add Audio to Video
75+
```csharp
76+
AudioManager.AddAudio("video.mp4", "sourceAudio.mp3");
77+
78+
await AudioManager.AddAudioAsync("video.mp4", "sourceAudio.mp3");
79+
```
80+
81+
This muxes the audio from the source file into the target video.
82+
83+
---
84+
## Initialization
85+
86+
The NuGet package supplies FFmpeg binaries. Initialization is only needed if you want to use custom binaries or a different location:
87+
88+
```csharp
89+
AudioManager.Initialize("ffmpeg.exe", "ffprobe.exe", "Temp");
90+
```
91+
92+
This sets up the executable paths and temporary directory used for conversions.
93+
94+
---
95+
## Notes
96+
97+
* All audio I/O uses FFmpeg under the hood.
98+
* Asynchronous methods use `Task` and support cancellation.
99+
* Audio data is handled in `float32` format internally.
100+
101+
---

TensorStack.Audio.Windows/TensorStack.Audio.Windows.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
<Title>$(AssemblyName)</Title>
2222
<PackageId>$(AssemblyName)</PackageId>
2323
<Product>$(AssemblyName)</Product>
24-
<Description></Description>
2524
<PackageIcon>Icon.png</PackageIcon>
25+
<PackageReadmeFile>README.md</PackageReadmeFile>
26+
<Description>Windows audio processing with FFmpeg integration.</Description>
2627
</PropertyGroup>
2728
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
2829
<None Remove="README.md" />
2930
<None Remove="Icon.png" />
3031
</ItemGroup>
3132
<ItemGroup Condition="'$(Configuration)' == 'Release'">
32-
<None Remove="Add.png" />
3333
<None Update="README.md">
3434
<Pack>True</Pack>
3535
<PackagePath>\</PackagePath>

TensorStack.Audio/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# TensorStack.Audio
2+
`TensorStack.Audio` provides the core, cross-platform abstractions for audio processing in TensorStack.
3+
It defines shared base classes used by platform-specific implementations such as **TensorStack.Audio.Windows** and **TensorStack.Audio.Linux**.
4+
5+
---

TensorStack.Audio/TensorStack.Audio.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,32 @@
33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
55
<PlatformTarget>x64</PlatformTarget>
6-
<Description></Description>
76
</PropertyGroup>
87

98
<!--Projects-->
109
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">
1110
<ProjectReference Include="..\TensorStack.Common\TensorStack.Common.csproj" />
1211
</ItemGroup>
1312

14-
<!--Packages-->
13+
<!--Packages-->
1514
<ItemGroup Condition=" '$(Configuration)' == 'Release'">
1615
<PackageReference Include="TensorStack.Common" Version="$(Version)" />
1716
</ItemGroup>
1817

19-
2018
<!--Nuget Settings-->
2119
<PropertyGroup>
2220
<Title>$(AssemblyName)</Title>
2321
<PackageId>$(AssemblyName)</PackageId>
2422
<Product>$(AssemblyName)</Product>
25-
<Description></Description>
2623
<PackageIcon>Icon.png</PackageIcon>
24+
<PackageReadmeFile>README.md</PackageReadmeFile>
25+
<Description>Audio processing and tensor conversion for .NET</Description>
2726
</PropertyGroup>
2827
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
2928
<None Remove="README.md" />
3029
<None Remove="Icon.png" />
3130
</ItemGroup>
3231
<ItemGroup Condition="'$(Configuration)' == 'Release'">
33-
<None Remove="Add.png" />
3432
<None Update="README.md">
3533
<Pack>True</Pack>
3634
<PackagePath>\</PackagePath>

TensorStack.Common/Common/ParameterCollection.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Microsoft.ML.OnnxRuntime;
44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76

87
namespace TensorStack.Common
98
{

TensorStack.Common/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
# TensorStack.Common
1+
# TensorStack.Common
2+
`TensorStack.Common` is the core library that contains shared functionality used across TensorStack projects.
3+
It includes the fundamental tensor types (ImageTensor, VideoTensor, AudioTensor) and base pipeline logic.
4+
It also provides utilities for managing ONNX sessions and models, handling automatic input type conversions, and simplifying the creation, use, and disposal of OrtValue objects.

TensorStack.Common/Tensor/VideoTensor.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// Licensed under the Apache 2.0 License.
33
using System;
44
using System.Collections.Generic;
5+
using System.Runtime.CompilerServices;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using TensorStack.Common.Video;
59

610
namespace TensorStack.Common.Tensor
711
{
@@ -92,6 +96,23 @@ public IEnumerable<ImageTensor> GetFrames()
9296
}
9397

9498

99+
/// <summary>
100+
/// Get an stream of VideoFrame
101+
/// </summary>
102+
/// <param name="cancellationToken">The cancellation token..</param>
103+
/// <returns>A Task&lt;IAsyncEnumerable`1&gt; representing the asynchronous operation.</returns>
104+
public async IAsyncEnumerable<VideoFrame> GetStreamAsync([EnumeratorCancellation] CancellationToken cancellationToken = default)
105+
{
106+
var index = 0;
107+
foreach (var frame in GetFrames())
108+
{
109+
cancellationToken.ThrowIfCancellationRequested();
110+
yield return new VideoFrame(index, frame, FrameRate);
111+
}
112+
await Task.Yield();
113+
}
114+
115+
95116
/// <summary>
96117
/// Called when Tensor data has changed
97118
/// </summary>

TensorStack.Common/TensorStack.Common.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
55
<PlatformTarget>x64</PlatformTarget>
6-
<Description></Description>
76
</PropertyGroup>
87

9-
<!--Nuget Packages-->
8+
<!--Common Packages-->
109
<ItemGroup>
1110
<PackageReference Include="System.Numerics.Tensors" Version="9.0.9" />
1211
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="1.23.0" />
@@ -19,13 +18,14 @@
1918
<Product>$(AssemblyName)</Product>
2019
<Description></Description>
2120
<PackageIcon>Icon.png</PackageIcon>
21+
<PackageReadmeFile>README.md</PackageReadmeFile>
22+
<Description>Core library for .NET handling tensors, pipelines, and ONNX model/session management.</Description>
2223
</PropertyGroup>
2324
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
2425
<None Remove="README.md" />
2526
<None Remove="Icon.png" />
2627
</ItemGroup>
2728
<ItemGroup Condition="'$(Configuration)' == 'Release'">
28-
<None Remove="Add.png" />
2929
<None Update="README.md">
3030
<Pack>True</Pack>
3131
<PackagePath>\</PackagePath>

TensorStack.Extractors/Common/ExtractorVideoOptions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright (c) TensorStack. All rights reserved.
22
// Licensed under the Apache 2.0 License.
3-
using TensorStack.Common;
43
using TensorStack.Common.Tensor;
54

65
namespace TensorStack.Extractors.Common

0 commit comments

Comments
 (0)