Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Streaming/REST Functionality and Introduce Microphone Example #253

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 51 additions & 7 deletions Deepgram.Dev.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,33 @@ 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("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "examples\streaming\file\Streaming.csproj", "{FD8507CC-EECF-4750-81AF-3CF8E536C007}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Deepgram.Microphone", "Deepgram.Microphone\Deepgram.Microphone.csproj", "{1D9621D6-8925-44DF-AE89-1381BF4514E4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{C673DFD1-528A-4BAE-94E6-02EF058AC363}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "speak", "speak", "{E2E3000D-FBBA-450E-A4E0-3542B38ADAFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "prerecorded", "prerecorded", "{77ACBABB-CF6B-4929-957C-480E29646DFD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "streaming", "streaming", "{132EEE99-6194-477A-9416-D7EF173C17FD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "file", "file", "{5E75479B-B84A-4386-9D3E-69CFB30B24C6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "microphone", "microphone", "{4D6C28C1-4D3F-4CFC-AF76-A389F6B00EC2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "file", "file", "{50BA802D-603E-4BD2-9A3E-AFDABC3AF43C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hello-world", "hello-world", "{AE6FFA55-DD91-4BC1-AFDF-96F64B5221CD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "url", "url", "{0414D1CF-79FB-4C5B-BF2B-88C3C1AA4C32}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Streaming", "examples\streaming\microphone\Streaming.csproj", "{74335799-3B43-432C-ACD9-FBF2AB32A64A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,10 +49,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 +57,36 @@ 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
{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
{74335799-3B43-432C-ACD9-FBF2AB32A64A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74335799-3B43-432C-ACD9-FBF2AB32A64A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74335799-3B43-432C-ACD9-FBF2AB32A64A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74335799-3B43-432C-ACD9-FBF2AB32A64A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{70B63CBA-1130-46D1-A022-6CD31C37C60E} = {0414D1CF-79FB-4C5B-BF2B-88C3C1AA4C32}
{C3AA63DB-4555-4BEF-B2DD-89A3B19A265B} = {AE6FFA55-DD91-4BC1-AFDF-96F64B5221CD}
{FD8507CC-EECF-4750-81AF-3CF8E536C007} = {5E75479B-B84A-4386-9D3E-69CFB30B24C6}
{E2E3000D-FBBA-450E-A4E0-3542B38ADAFD} = {C673DFD1-528A-4BAE-94E6-02EF058AC363}
{77ACBABB-CF6B-4929-957C-480E29646DFD} = {C673DFD1-528A-4BAE-94E6-02EF058AC363}
{132EEE99-6194-477A-9416-D7EF173C17FD} = {C673DFD1-528A-4BAE-94E6-02EF058AC363}
{5E75479B-B84A-4386-9D3E-69CFB30B24C6} = {132EEE99-6194-477A-9416-D7EF173C17FD}
{4D6C28C1-4D3F-4CFC-AF76-A389F6B00EC2} = {132EEE99-6194-477A-9416-D7EF173C17FD}
{50BA802D-603E-4BD2-9A3E-AFDABC3AF43C} = {E2E3000D-FBBA-450E-A4E0-3542B38ADAFD}
{AE6FFA55-DD91-4BC1-AFDF-96F64B5221CD} = {50BA802D-603E-4BD2-9A3E-AFDABC3AF43C}
{0414D1CF-79FB-4C5B-BF2B-88C3C1AA4C32} = {77ACBABB-CF6B-4929-957C-480E29646DFD}
{74335799-3B43-432C-ACD9-FBF2AB32A64A} = {4D6C28C1-4D3F-4CFC-AF76-A389F6B00EC2}
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
davidvonthenen marked this conversation as resolved.
Show resolved Hide resolved
Console.WriteLine("Portaudio Version: {0}\n\n", PortAudio.VersionInfo.versionText);
PortAudio.Initialize();
}

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