using System;
namespace DeepSpeechClient.Interfaces
{
///
/// Client interface of the Mozilla's deepspeech implementation.
///
public interface IDeepSpeech : IDisposable
{
///
/// Prints the versions of Tensorflow and DeepSpeech.
///
void PrintVersions();
///
/// Create an object providing an interface to a trained DeepSpeech model.
///
/// The path to the frozen model graph.
/// The number of cepstrum the model was trained with.
/// The context window the model was trained with.
/// The path to the configuration file specifying the alphabet used by the network.
/// The beam width used by the decoder. A larger beam width generates better results at the cost of decoding time.
/// Zero on success, non-zero on failure.
unsafe int CreateModel(string aModelPath, uint aNCep,
uint aNContext,
string aAlphabetConfigPath,
uint aBeamWidth);
///
/// Enable decoding using beam scoring with a KenLM language model.
///
/// The path to the configuration file specifying the alphabet used by the network.
/// The path to the language model binary file.
/// The path to the trie file build from the same vocabulary as the language model binary.
/// The alpha hyperparameter of the CTC decoder. Language Model weight.
/// The beta hyperparameter of the CTC decoder. Word insertion weight.
/// Zero on success, non-zero on failure (invalid arguments).
unsafe int EnableDecoderWithLM(string aAlphabetConfigPath,
string aLMPath,
string aTriePath,
float aLMAlpha,
float aLMBeta);
///
/// Use the DeepSpeech model to perform Speech-To-Text.
///
/// A 16-bit, mono raw audio signal at the appropriate sample rate.
/// The number of samples in the audio signal.
/// The sample-rate of the audio signal.
/// The STT result. The user is responsible for freeing the string. Returns NULL on error.
unsafe string SpeechToText(short[] aBuffer,
uint aBufferSize,
uint aSampleRate);
///
/// 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.
///
unsafe void DiscardStream();
///
/// Creates a new streaming inference state.
///
/// Number of timestep frames to reserve.
/// One timestep is equivalent to two window lengths(20ms).
/// If set to 0 we reserve enough frames for 3 seconds of audio(150).
/// The sample-rate of the audio signal
/// Zero for success, non-zero on failure
unsafe int SetupStream(uint aPreAllocFrames, uint aSampleRate);
///
/// Feeds audio samples to an ongoing streaming inference.
///
/// An array of 16-bit, mono raw audio samples at the appropriate sample rate.
unsafe void FeedAudioContent(short[] aBuffer, uint aBufferSize);
///
/// Computes the intermediate decoding of an ongoing streaming inference. This is an expensive process as the decoder implementation isn't
/// currently capable of streaming, so it always starts from the beginning of the audio.
///
/// The STT intermediate result. The user is responsible for freeing the string.
unsafe string IntermediateDecode();
///
/// Closes the ongoing streaming inference, returns the STT result over the whole audio signal.
///
/// The STT result. The user is responsible for freeing the string.
unsafe string FinishStream();
}
}