Skip to content

Commit

Permalink
Merge pull request #2154 from jetelain/fix-dotnet
Browse files Browse the repository at this point in the history
Fix .net build
  • Loading branch information
reuben authored Mar 7, 2022
2 parents 873b90c + f29745d commit 45f5b4f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 37 deletions.
4 changes: 2 additions & 2 deletions native_client/dotnet/STTClient/Extensions/NativeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static Models.CandidateTranscript PtrToCandidateTranscript(this IntPtr i
managedTranscript.Confidence = transcript.confidence;

//we need to manually read each item from the native ptr using its size
var sizeOfTokenMetadata = Marshal.SizeOf(typeof(TokenMetadata));
var sizeOfTokenMetadata = Marshal.SizeOf<TokenMetadata>();
for (int i = 0; i < transcript.num_tokens; i++)
{
managedTranscript.Tokens[i] = transcript.tokens.PtrToTokenMetadata();
Expand All @@ -79,7 +79,7 @@ internal static Models.Metadata PtrToMetadata(this IntPtr intPtr)
managedMetadata.Transcripts = new Models.CandidateTranscript[metadata.num_transcripts];

//we need to manually read each item from the native ptr using its size
var sizeOfCandidateTranscript = Marshal.SizeOf(typeof(CandidateTranscript));
var sizeOfCandidateTranscript = Marshal.SizeOf<CandidateTranscript>();
for (int i = 0; i < metadata.num_transcripts; i++)
{
managedMetadata.Transcripts[i] = metadata.transcripts.PtrToCandidateTranscript();
Expand Down
14 changes: 7 additions & 7 deletions native_client/dotnet/STTClient/Interfaces/ISTT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,48 +104,48 @@ unsafe Metadata SpeechToTextWithMetadata(short[] aBuffer,
/// This can be used if you no longer need the result of an ongoing streaming
/// inference and don't want to perform a costly decode operation.
/// </summary>
unsafe void FreeStream(Stream stream);
unsafe void FreeStream(STTStream stream);

/// <summary>
/// Creates a new streaming inference state.
/// </summary>
unsafe Stream CreateStream();
unsafe STTStream CreateStream();

/// <summary>
/// Feeds audio samples to an ongoing streaming inference.
/// </summary>
/// <param name="stream">Instance of the stream to feed the data.</param>
/// <param name="aBuffer">An array of 16-bit, mono raw audio samples at the appropriate sample rate (matching what the model was trained on).</param>
unsafe void FeedAudioContent(Stream stream, short[] aBuffer, uint aBufferSize);
unsafe void FeedAudioContent(STTStream stream, short[] aBuffer, uint aBufferSize);

/// <summary>
/// Computes the intermediate decoding of an ongoing streaming inference.
/// </summary>
/// <param name="stream">Instance of the stream to decode.</param>
/// <returns>The STT intermediate result.</returns>
unsafe string IntermediateDecode(Stream stream);
unsafe string IntermediateDecode(STTStream stream);

/// <summary>
/// Computes the intermediate decoding of an ongoing streaming inference, including metadata.
/// </summary>
/// <param name="stream">Instance of the stream to decode.</param>
/// <param name="aNumResults">Maximum number of candidate transcripts to return. Returned list might be smaller than this.</param>
/// <returns>The extended metadata result.</returns>
unsafe Metadata IntermediateDecodeWithMetadata(Stream stream, uint aNumResults);
unsafe Metadata IntermediateDecodeWithMetadata(STTStream stream, uint aNumResults);

/// <summary>
/// Closes the ongoing streaming inference, returns the STT result over the whole audio signal.
/// </summary>
/// <param name="stream">Instance of the stream to finish.</param>
/// <returns>The STT result.</returns>
unsafe string FinishStream(Stream stream);
unsafe string FinishStream(STTStream stream);

/// <summary>
/// Closes the ongoing streaming inference, returns the STT result over the whole audio signal, including metadata.
/// </summary>
/// <param name="stream">Instance of the stream to finish.</param>
/// <param name="aNumResults">Maximum number of candidate transcripts to return. Returned list might be smaller than this.</param>
/// <returns>The extended metadata result.</returns>
unsafe Metadata FinishStreamWithMetadata(Stream stream, uint aNumResults);
unsafe Metadata FinishStreamWithMetadata(STTStream stream, uint aNumResults);
}
}
2 changes: 1 addition & 1 deletion native_client/dotnet/STTClient/STT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public unsafe STTStream CreateStream()
IntPtr** streamingStatePointer = null;
var resultCode = NativeImp.STT_CreateStream(_modelStatePP, ref streamingStatePointer);
EvaluateResultCode(resultCode);
return new Stream(streamingStatePointer);
return new STTStream(streamingStatePointer);
}

/// <summary>
Expand Down
29 changes: 2 additions & 27 deletions native_client/dotnet/STTClient/STTClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net452;net46;net47;uap10.0</TargetFrameworks>
<OutputType>Library</OutputType>
<TargetFrameworks>netstandard1.6</TargetFrameworks>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand All @@ -14,29 +14,4 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'uap10.0'">
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
<NugetTargetMoniker>UAP,Version=v10.0</NugetTargetMoniker>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
<TargetFrameworkIdentifier>.NETCore</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<DefineConstants>$(DefineConstants);WINDOWS_UWP</DefineConstants>
<LanguageTargets>$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets</LanguageTargets>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform " Version="5.2.2" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>


<PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
<DefineConstants>$(DefineConstants);NO_HTTPS</DefineConstants>
</PropertyGroup>
</Project>

0 comments on commit 45f5b4f

Please sign in to comment.