Пример #1
0
        /// <summary>
        /// Use the DeepSpeech model to perform Speech-To-Text.
        /// </summary>
        /// <param name="aBuffer">A 16-bit, mono raw audio signal at the appropriate sample rate.</param>
        /// <param name="aBufferSize">The number of samples in the audio signal.</param>
        /// <param name="aSampleRate">The sample-rate of the audio signal.</param>
        /// <returns>The STT result. The user is responsible for freeing the string.  Returns NULL on error.</returns>
        public unsafe string SpeechToText(short[] aBuffer, uint aBufferSize, uint aSampleRate)
        {
            var res = NativeImp.DS_SpeechToText(_modelStatePP, aBuffer, aBufferSize, aSampleRate);

            int len = 0;

            while (Marshal.ReadByte(res, len) != 0)
            {
                ++len;
            }
            byte[] buffer = new byte[len];
            Marshal.Copy(res, buffer, 0, buffer.Length);
            return(Encoding.UTF8.GetString(buffer));
        }
Пример #2
0
 /// <summary>
 /// Use the DeepSpeech 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>
 public unsafe string SpeechToText(short[] aBuffer, uint aBufferSize)
 {
     return(NativeImp.DS_SpeechToText(_modelStatePP, aBuffer, aBufferSize).PtrToString());
 }
Пример #3
0
 /// <summary>
 /// Use the DeepSpeech model to perform Speech-To-Text.
 /// </summary>
 /// <param name="aBuffer">A 16-bit, mono raw audio signal at the appropriate sample rate.</param>
 /// <param name="aBufferSize">The number of samples in the audio signal.</param>
 /// <param name="aSampleRate">The sample-rate of the audio signal.</param>
 /// <returns>The STT result. The user is responsible for freeing the string.  Returns NULL on error.</returns>
 public unsafe string SpeechToText(short[] aBuffer, uint aBufferSize, uint aSampleRate)
 {
     return(NativeImp.DS_SpeechToText(_modelStatePP, aBuffer, aBufferSize, aSampleRate));
 }