Add .Net API usage example
This commit is contained in:
parent
e22890c251
commit
2b51316d68
29
doc/DotNet-Examples.rst
Normal file
29
doc/DotNet-Examples.rst
Normal file
@ -0,0 +1,29 @@
|
||||
.Net API Usage example
|
||||
======================
|
||||
|
||||
Examples are from `native_client/dotnet/DeepSpeechConsole/Program.cs`.
|
||||
|
||||
Creating a model instance and loading model
|
||||
-------------------------------------------
|
||||
|
||||
.. literalinclude:: ../native_client/dotnet/DeepSpeechConsole/Program.cs
|
||||
:language: csharp
|
||||
:linenos:
|
||||
:lineno-match:
|
||||
:start-after: sphinx-doc: csharp_ref_model_start
|
||||
:end-before: sphinx-doc: csharp_ref_model_stop
|
||||
|
||||
Performing inference
|
||||
--------------------
|
||||
|
||||
.. literalinclude:: ../native_client/dotnet/DeepSpeechConsole/Program.cs
|
||||
:language: csharp
|
||||
:linenos:
|
||||
:lineno-match:
|
||||
:start-after: sphinx-doc: csharp_ref_inference_start
|
||||
:end-before: sphinx-doc: csharp_ref_inference_stop
|
||||
|
||||
Full source code
|
||||
----------------
|
||||
|
||||
See :download:`Full source code<../native_client/dotnet/DeepSpeechConsole/Program.cs>`.
|
@ -54,17 +54,19 @@ Welcome to DeepSpeech's documentation!
|
||||
|
||||
C-Examples
|
||||
|
||||
NodeJS-Examples
|
||||
DotNet-Examples
|
||||
|
||||
Java-Examples
|
||||
|
||||
NodeJS-Examples
|
||||
|
||||
Python-Examples
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contributed examples
|
||||
|
||||
DotNet-contrib-examples.rst
|
||||
DotNet-contrib-examples
|
||||
|
||||
NodeJS-contrib-Examples
|
||||
|
||||
|
@ -51,8 +51,10 @@ namespace CSharpExamples
|
||||
{
|
||||
Console.WriteLine("Loading model...");
|
||||
stopwatch.Start();
|
||||
// sphinx-doc: csharp_ref_model_start
|
||||
using (IDeepSpeech sttClient = new DeepSpeech(model ?? "output_graph.pbmm"))
|
||||
{
|
||||
// sphinx-doc: csharp_ref_model_stop
|
||||
stopwatch.Stop();
|
||||
|
||||
Console.WriteLine($"Model loaded - {stopwatch.Elapsed.Milliseconds} ms");
|
||||
@ -72,6 +74,7 @@ namespace CSharpExamples
|
||||
stopwatch.Start();
|
||||
|
||||
string speechResult;
|
||||
// sphinx-doc: csharp_ref_inference_start
|
||||
if (extended)
|
||||
{
|
||||
Metadata metaResult = sttClient.SpeechToTextWithMetadata(waveBuffer.ShortBuffer,
|
||||
@ -83,6 +86,7 @@ namespace CSharpExamples
|
||||
speechResult = sttClient.SpeechToText(waveBuffer.ShortBuffer,
|
||||
Convert.ToUInt32(waveBuffer.MaxSize / 2));
|
||||
}
|
||||
// sphinx-doc: csharp_ref_inference_stop
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
@ -99,4 +103,4 @@ namespace CSharpExamples
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user