Skip to content

Commit

Permalink
Streaming Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
dvonthenen committed Mar 28, 2024
1 parent e62992e commit c1fe3eb
Show file tree
Hide file tree
Showing 55 changed files with 835 additions and 271 deletions.
67 changes: 60 additions & 7 deletions Deepgram.Dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,39 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Deepgram", "Deepgram\Deepgr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Deepgram.Tests", "Deepgram.Tests\Deepgram.Tests.csproj", "{12C80273-08DD-494C-B06D-DFC6D40B1D95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "examples\streaming\Streaming.csproj", "{5DD81E37-D575-476B-9D1C-803A093A4E3C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PreRecorded", "examples\prerecorded\file\PreRecorded.csproj", "{70B63CBA-1130-46D1-A022-6CD31C37C60E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Prerecorded", "examples\prerecorded\Prerecorded.csproj", "{70B63CBA-1130-46D1-A022-6CD31C37C60E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speak", "examples\speak\file\hello-world\Speak.csproj", "{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Speak", "examples\speak\Speak.csproj", "{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{34821A99-3DF4-42CA-B12D-F6D30AB11BFC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "speak", "speak", "{2D46D7C4-2CEE-4EC4-BFD4-A8ACB41A6FB0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "streaming", "streaming", "{B675976B-59A1-4827-9F0E-ADBE70109175}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "analyze", "analyze", "{759F3200-CE05-4164-84A1-61B3FED028A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "prerecorded", "prerecorded", "{5791AC6B-A202-4DED-8788-CD4451C35755}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "manage", "manage", "{6ADFF8A2-1114-4419-83E3-14B05DF3056E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "advanced", "advanced", "{048DB116-04EF-468E-83F2-DE9E13F873FD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "file", "file", "{CD2B8E2D-9D95-46DE-899A-CD6E49449CA1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "file", "file", "{EAED4363-A298-4511-9941-31512FBA1FAF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hello-world", "hello-world", "{80C7E9DD-18A8-4A24-AAF9-8BE7484A0D05}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "microphone", "microphone", "{4F2E8A7F-A634-470F-8897-F5F14DBDA2CB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "file", "file", "{9A92C390-7E41-40B6-BF22-6D63B4FB6C64}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "examples\streaming\file\Streaming.csproj", "{FD8507CC-EECF-4750-81AF-3CF8E536C007}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "examples\streaming\microphone\Streaming.csproj", "{647D3479-6725-45D0-A5F4-51D1B6E9C256}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Deepgram.Microphone", "Deepgram.Microphone\Deepgram.Microphone.csproj", "{1D9621D6-8925-44DF-AE89-1381BF4514E4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,10 +55,6 @@ Global
{12C80273-08DD-494C-B06D-DFC6D40B1D95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12C80273-08DD-494C-B06D-DFC6D40B1D95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12C80273-08DD-494C-B06D-DFC6D40B1D95}.Release|Any CPU.Build.0 = Release|Any CPU
{5DD81E37-D575-476B-9D1C-803A093A4E3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DD81E37-D575-476B-9D1C-803A093A4E3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DD81E37-D575-476B-9D1C-803A093A4E3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DD81E37-D575-476B-9D1C-803A093A4E3C}.Release|Any CPU.Build.0 = Release|Any CPU
{70B63CBA-1130-46D1-A022-6CD31C37C60E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70B63CBA-1130-46D1-A022-6CD31C37C60E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70B63CBA-1130-46D1-A022-6CD31C37C60E}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -39,10 +63,39 @@ Global
{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B}.Release|Any CPU.Build.0 = Release|Any CPU
{FD8507CC-EECF-4750-81AF-3CF8E536C007}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD8507CC-EECF-4750-81AF-3CF8E536C007}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD8507CC-EECF-4750-81AF-3CF8E536C007}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD8507CC-EECF-4750-81AF-3CF8E536C007}.Release|Any CPU.Build.0 = Release|Any CPU
{647D3479-6725-45D0-A5F4-51D1B6E9C256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{647D3479-6725-45D0-A5F4-51D1B6E9C256}.Debug|Any CPU.Build.0 = Debug|Any CPU
{647D3479-6725-45D0-A5F4-51D1B6E9C256}.Release|Any CPU.ActiveCfg = Release|Any CPU
{647D3479-6725-45D0-A5F4-51D1B6E9C256}.Release|Any CPU.Build.0 = Release|Any CPU
{1D9621D6-8925-44DF-AE89-1381BF4514E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D9621D6-8925-44DF-AE89-1381BF4514E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D9621D6-8925-44DF-AE89-1381BF4514E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D9621D6-8925-44DF-AE89-1381BF4514E4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{70B63CBA-1130-46D1-A022-6CD31C37C60E} = {CD2B8E2D-9D95-46DE-899A-CD6E49449CA1}
{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B} = {80C7E9DD-18A8-4A24-AAF9-8BE7484A0D05}
{2D46D7C4-2CEE-4EC4-BFD4-A8ACB41A6FB0} = {34821A99-3DF4-42CA-B12D-F6D30AB11BFC}
{B675976B-59A1-4827-9F0E-ADBE70109175} = {34821A99-3DF4-42CA-B12D-F6D30AB11BFC}
{759F3200-CE05-4164-84A1-61B3FED028A6} = {34821A99-3DF4-42CA-B12D-F6D30AB11BFC}
{5791AC6B-A202-4DED-8788-CD4451C35755} = {34821A99-3DF4-42CA-B12D-F6D30AB11BFC}
{6ADFF8A2-1114-4419-83E3-14B05DF3056E} = {34821A99-3DF4-42CA-B12D-F6D30AB11BFC}
{048DB116-04EF-468E-83F2-DE9E13F873FD} = {34821A99-3DF4-42CA-B12D-F6D30AB11BFC}
{CD2B8E2D-9D95-46DE-899A-CD6E49449CA1} = {5791AC6B-A202-4DED-8788-CD4451C35755}
{EAED4363-A298-4511-9941-31512FBA1FAF} = {2D46D7C4-2CEE-4EC4-BFD4-A8ACB41A6FB0}
{80C7E9DD-18A8-4A24-AAF9-8BE7484A0D05} = {EAED4363-A298-4511-9941-31512FBA1FAF}
{4F2E8A7F-A634-470F-8897-F5F14DBDA2CB} = {B675976B-59A1-4827-9F0E-ADBE70109175}
{9A92C390-7E41-40B6-BF22-6D63B4FB6C64} = {B675976B-59A1-4827-9F0E-ADBE70109175}
{FD8507CC-EECF-4750-81AF-3CF8E536C007} = {9A92C390-7E41-40B6-BF22-6D63B4FB6C64}
{647D3479-6725-45D0-A5F4-51D1B6E9C256} = {4F2E8A7F-A634-470F-8897-F5F14DBDA2CB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D4ABC6D-7126-4EE2-9303-43A954616B2A}
EndGlobalSection
Expand Down
10 changes: 6 additions & 4 deletions Deepgram.DevBuild.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31912.275
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Deepgram", "Deepgram\Deepgram.csproj", "{1F72D53C-2EF5-4556-A0E6-18D57BF9648B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Deepgram.Microphone", "Deepgram.Microphone\Deepgram.Microphone.csproj", "{E9374C11-B475-4692-9D46-C2734756CFA3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,10 +17,10 @@ Global
{1F72D53C-2EF5-4556-A0E6-18D57BF9648B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F72D53C-2EF5-4556-A0E6-18D57BF9648B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F72D53C-2EF5-4556-A0E6-18D57BF9648B}.Release|Any CPU.Build.0 = Release|Any CPU
{ED1EF53E-BA86-44FA-B1C0-484B3864E459}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED1EF53E-BA86-44FA-B1C0-484B3864E459}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED1EF53E-BA86-44FA-B1C0-484B3864E459}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED1EF53E-BA86-44FA-B1C0-484B3864E459}.Release|Any CPU.Build.0 = Release|Any CPU
{E9374C11-B475-4692-9D46-C2734756CFA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9374C11-B475-4692-9D46-C2734756CFA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9374C11-B475-4692-9D46-C2734756CFA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9374C11-B475-4692-9D46-C2734756CFA3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
20 changes: 20 additions & 0 deletions Deepgram.Microphone/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace Deepgram.Microphone;

public static class Defaults
{
// Default sample rate
public const int RATE = 16000;

// Number of channels
public const int CHANNELS = 1;

// Default chunk size
public const int CHUNK_SIZE = 8194;

// Default input device index
public const SampleFormat SAMPLE_FORMAT = SampleFormat.Int16;

// Default input device index
public const int DEVICE_INDEX = PortAudio.NoDevice;
}

125 changes: 125 additions & 0 deletions Deepgram.Microphone/Deepgram.Microphone.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0;net8.0;netstandard2.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(SolutionFileName)' == 'Deepgram.sln'">
<!-- Properties related to NuGet packaging: -->
<IsPackable>true</IsPackable>
<Company>Deepgram</Company>
<PackageId>Deepgram.Microphone</PackageId>
<Title>Deepgram .NET Microphone</Title>
<Description>Helper Microphone Package</Description>
<Summary>Helper Microphone Package</Summary>
<Authors>Deepgram .NET SDK Contributors</Authors>
<Copyright>2024 Deepgram</Copyright>
<PackageIcon>dg_logo.png</PackageIcon>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://developers.deepgram.com/sdks-tools/sdks/dotnet-sdk/</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/deepgram/deepgram-dotnet-sdk</RepositoryUrl>
<PackageTags>speech-to-text,captions,speech-recognition,deepgram,dotnet</PackageTags>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(SolutionFileName)' == 'Deepgram.DevBuild.sln'">
<!-- Properties related to NuGet packaging: -->
<IsPackable>true</IsPackable>
<Company>Deepgram</Company>
<PackageId>Deepgram.Unstable.Microphone.Builds</PackageId>
<Title>Deepgram.Microphone - UNSTABLE DEVELOPER BUILDS</Title>
<Description>UNSTABLE DEVELOPER BUILDS - Deepgram .NET Microphone</Description>
<Summary>UNSTABLE DEVELOPER BUILDS - Deepgram .NET Microphone</Summary>
<Authors>Deepgram .NET SDK Contributors</Authors>
<Copyright>2024 Deepgram</Copyright>
<PackageIcon>dg_logo.png</PackageIcon>
<PackageRequireLicenseAcceptance>False</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://developers.deepgram.com/sdks-tools/sdks/dotnet-sdk/</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/deepgram/deepgram-dotnet-sdk</RepositoryUrl>
<PackageTags>speech-to-text,captions,speech-recognition,deepgram,dotnet</PackageTags>
<EnableNETAnalyzers>True</EnableNETAnalyzers>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.*" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.*" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="6.*" />
<PackageReference Include="System.Threading.Channels" Version="6.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.1" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.*" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.*" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.*" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="7.*" />
<PackageReference Include="System.Threading.Channels" Version="7.*" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.*" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.*" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="System.Text.Json" Version="8.*" />
<PackageReference Include="System.Threading.Channels" Version="8.*" />
</ItemGroup>


<ItemGroup>
<None Include="..\extras\dg_logo.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="PortAudioSharp2" Version="1.0.0" />
</ItemGroup>

</Project>
5 changes: 5 additions & 0 deletions Deepgram.Microphone/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT

global using PortAudioSharp;
19 changes: 19 additions & 0 deletions Deepgram.Microphone/Library.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

namespace Deepgram.Microphone;

public class Library
{
public static void Initialize()
{
// TODO: logging
Console.WriteLine("Portaudio Version: {0}\n\n", PortAudio.VersionInfo.versionText);
PortAudio.Initialize();
}

public static void Terminate()
{
// TODO: logging
// Terminate PortAudio
PortAudio.Terminate();
}
}
Loading

0 comments on commit c1fe3eb

Please sign in to comment.