More renames

This commit is contained in:
Reuben Morais 2020-08-04 17:29:07 +02:00
parent ee1235678d
commit 4d726e820d
5 changed files with 105 additions and 139 deletions

View File

@ -1,130 +0,0 @@
using MozillaVoiceSttClient.Models;
using System;
using System.IO;
namespace MozillaVoiceSttClient.Interfaces
{
/// <summary>
/// Client interface of Mozilla Voice STT.
/// </summary>
public interface IModel : IDisposable
{
/// <summary>
/// Return version of this library. The returned version is a semantic version
/// (SemVer 2.0.0).
/// </summary>
unsafe string Version();
/// <summary>
/// Return the sample rate expected by the model.
/// </summary>
/// <returns>Sample rate.</returns>
unsafe int GetModelSampleRate();
/// <summary>
/// Get beam width value used by the model. If SetModelBeamWidth was not
/// called before, will return the default value loaded from the model
/// file.
/// </summary>
/// <returns>Beam width value used by the model.</returns>
unsafe uint GetModelBeamWidth();
/// <summary>
/// Set beam width value used by the model.
/// </summary>
/// <param name="aBeamWidth">The beam width used by the decoder. A larger beam width value generates better results at the cost of decoding time.</param>
/// <exception cref="ArgumentException">Thrown on failure.</exception>
unsafe void SetModelBeamWidth(uint aBeamWidth);
/// <summary>
/// Enable decoding using an external scorer.
/// </summary>
/// <param name="aScorerPath">The path to the external scorer file.</param>
/// <exception cref="ArgumentException">Thrown when the native binary failed to enable decoding with an external scorer.</exception>
/// <exception cref="FileNotFoundException">Thrown when cannot find the scorer file.</exception>
unsafe void EnableExternalScorer(string aScorerPath);
/// <summary>
/// Disable decoding using an external scorer.
/// </summary>
/// <exception cref="ArgumentException">Thrown when an external scorer is not enabled.</exception>
unsafe void DisableExternalScorer();
/// <summary>
/// Set hyperparameters alpha and beta of the external scorer.
/// </summary>
/// <param name="aAlpha">The alpha hyperparameter of the decoder. Language model weight.</param>
/// <param name="aBeta">The beta hyperparameter of the decoder. Word insertion weight.</param>
/// <exception cref="ArgumentException">Thrown when an external scorer is not enabled.</exception>
unsafe void SetScorerAlphaBeta(float aAlpha, float aBeta);
/// <summary>
/// Use the Mozilla Voice STT model to perform Speech-To-Text.
/// </summary>
/// <param name="aBuffer">A 16-bit, mono raw audio signal at the appropriate sample rate (matching what the model was trained on).</param>
/// <param name="aBufferSize">The number of samples in the audio signal.</param>
/// <returns>The STT result. Returns NULL on error.</returns>
unsafe string SpeechToText(short[] aBuffer,
uint aBufferSize);
/// <summary>
/// Use the Mozilla Voice STT model to perform Speech-To-Text, return results including metadata.
/// </summary>
/// <param name="aBuffer">A 16-bit, mono raw audio signal at the appropriate sample rate (matching what the model was trained on).</param>
/// <param name="aBufferSize">The number of samples in the audio signal.</param>
/// <param name="aNumResults">Maximum number of candidate transcripts to return. Returned list might be smaller than this.</param>
/// <returns>The extended metadata. Returns NULL on error.</returns>
unsafe Metadata SpeechToTextWithMetadata(short[] aBuffer,
uint aBufferSize,
uint aNumResults);
/// <summary>
/// Destroy a streaming state without decoding the computed logits.
/// 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(MozillaVoiceSttStream stream);
/// <summary>
/// Creates a new streaming inference state.
/// </summary>
unsafe MozillaVoiceSttStream 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(MozillaVoiceSttStream 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(MozillaVoiceSttStream 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(MozillaVoiceSttStream 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(MozillaVoiceSttStream 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(MozillaVoiceSttStream stream, uint aNumResults);
}
}

View File

@ -1,12 +1,12 @@
using MozillaVoiceStt.Interfaces;
using MozillaVoiceStt.Extensions;
using MozillaVoiceSttClient.Interfaces;
using MozillaVoiceSttClient.Extensions;
using System;
using System.IO;
using MozillaVoiceStt.Enums;
using MozillaVoiceStt.Models;
namespace MozillaVoiceStt
namespace MozillaVoiceSttClient
{
/// <summary>
/// Concrete implementation of <see cref="MozillaVoiceStt.Interfaces.IMozillaVoiceSttModel"/>.

View File

@ -15,8 +15,8 @@ public class MozillaVoiceSttModel {
private SWIGTYPE_p_ModelState _msp;
private void evaluateErrorCode(int errorCode) {
STT_Error_Codes code = STT_Error_Codes.swigToEnum(errorCode);
if (code != STT_Error_Codes.ERR_OK) {
Error_Codes code = Error_Codes.swigToEnum(errorCode);
if (code != Error_Codes.ERR_OK) {
throw new RuntimeException("Error: " + impl.ErrorCodeToErrorMessage(errorCode) + " (0x" + Integer.toHexString(errorCode) + ").");
}
}

View File

@ -8,11 +8,11 @@
/* Begin PBXBuildFile section */
502AED2D24D9676500E9A4AD /* mozilla_voice_stt.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 502AED2C24D9676500E9A4AD /* mozilla_voice_stt.framework */; };
502AED3024D9677B00E9A4AD /* mozilla_voice_stt.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 502AED2E24D9677000E9A4AD /* mozilla_voice_stt.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
504EC34324CF4EFD0073C22E /* SpeechRecognitionImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC34124CF4EFD0073C22E /* SpeechRecognitionImpl.swift */; };
504EC34424CF4EFD0073C22E /* AudioContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 504EC34224CF4EFD0073C22E /* AudioContext.swift */; };
507CD3A324B61FEB00409BBB /* libmozilla_voice_stt.so in Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD3A224B61FEA00409BBB /* libmozilla_voice_stt.so */; };
507CD3A424B61FFC00409BBB /* libmozilla_voice_stt.so in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 507CD3A224B61FEA00409BBB /* libmozilla_voice_stt.so */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
509DF81924D9B2C200D1026D /* mozilla_voice_stt.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 502AED2C24D9676500E9A4AD /* mozilla_voice_stt.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
50F787F32497683900D52237 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F787F22497683900D52237 /* AppDelegate.swift */; };
50F787F52497683900D52237 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F787F42497683900D52237 /* SceneDelegate.swift */; };
50F787F72497683900D52237 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F787F62497683900D52237 /* ContentView.swift */; };
@ -45,7 +45,7 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
502AED3024D9677B00E9A4AD /* mozilla_voice_stt.framework in Embed Frameworks */,
509DF81924D9B2C200D1026D /* mozilla_voice_stt.framework in Embed Frameworks */,
507CD3A424B61FFC00409BBB /* libmozilla_voice_stt.so in Embed Frameworks */,
);
name = "Embed Frameworks";
@ -55,7 +55,6 @@
/* Begin PBXFileReference section */
502AED2C24D9676500E9A4AD /* mozilla_voice_stt.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = mozilla_voice_stt.framework; sourceTree = BUILT_PRODUCTS_DIR; };
502AED2E24D9677000E9A4AD /* mozilla_voice_stt.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mozilla_voice_stt.framework; path = "DerivedData/mozilla_voice_stt/Build/Products/Debug-iphoneos/mozilla_voice_stt.framework"; sourceTree = "<group>"; };
504EC34124CF4EFD0073C22E /* SpeechRecognitionImpl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SpeechRecognitionImpl.swift; sourceTree = "<group>"; };
504EC34224CF4EFD0073C22E /* AudioContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioContext.swift; sourceTree = "<group>"; };
507CD3A224B61FEA00409BBB /* libmozilla_voice_stt.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libmozilla_voice_stt.so; sourceTree = "<group>"; };
@ -110,7 +109,6 @@
50F787E62497683900D52237 = {
isa = PBXGroup;
children = (
502AED2E24D9677000E9A4AD /* mozilla_voice_stt.framework */,
50F787F12497683900D52237 /* mozilla_voice_stt_test */,
50F787F02497683900D52237 /* Products */,
50F2B0FC2498D6C7007CD876 /* Frameworks */,

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1160"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "50F787EE2497683900D52237"
BuildableName = "mozilla_voice_stt_test.app"
BlueprintName = "mozilla_voice_stt_test"
ReferencedContainer = "container:mozilla_voice_stt_test.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "50F788042497683A00D52237"
BuildableName = "mozilla_voice_stt_testTests.xctest"
BlueprintName = "mozilla_voice_stt_testTests"
ReferencedContainer = "container:mozilla_voice_stt_test.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "50F7880F2497683A00D52237"
BuildableName = "mozilla_voice_stt_testUITests.xctest"
BlueprintName = "mozilla_voice_stt_testUITests"
ReferencedContainer = "container:mozilla_voice_stt_test.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "50F787EE2497683900D52237"
BuildableName = "mozilla_voice_stt_test.app"
BlueprintName = "mozilla_voice_stt_test"
ReferencedContainer = "container:mozilla_voice_stt_test.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "50F787EE2497683900D52237"
BuildableName = "mozilla_voice_stt_test.app"
BlueprintName = "mozilla_voice_stt_test"
ReferencedContainer = "container:mozilla_voice_stt_test.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>