Example #1
0
 public SpeechAudio(WaveStream stream, WaveFormat format, SpeechAudioChannel channel = SpeechAudioChannel.Mono)
     : this(stream, "unknown.wav", channel)
 {
     if (!Stream.WaveFormat.Equals(format))
     {
         Format   = format;
         Provider = new MediaFoundationResampler(Stream, format);
     }
 }
 public virtual bool AppendStereo(string filename, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         var waveStream = new WaveFileReader(filename);
         Logger?.LogDebug("SpeechEnrollerBase.AppendStereo(): Filename: " + filename);
         return(AppendStereo(waveStream, channel));
     }
     return(false);
 }
 public virtual void PostStereo(string filename, SpeechAudioChannel channel, SpeechEnroller.PostCallback callback)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(filename, channel))
         {
             Post(callback);
         }
     }
 }
 public virtual void PostStereo(WaveStream stream, SpeechAudioChannel channel, SpeechEnroller.PostCallback callback)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             Post(callback);
         }
     }
 }
 public virtual void PostStereo(WaveStream stream, SpeechContexts contexts, SpeechAudioChannel channel, SpeechVerifier.PostCallback callback)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, contexts, channel))
         {
             Post(callback);
         }
     }
 }
 public virtual Task <SpeechEnroller.Result> PostStereoAsync(string filename, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(filename, channel))
         {
             return(PostAsync());
         }
     }
     return(Task.FromResult(SpeechEnroller.Result.Invalid));
 }
 public virtual SpeechEnroller.Result PostStereo(WaveStream stream, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             return(Post());
         }
     }
     return(SpeechEnroller.Result.Invalid);
 }
 public virtual bool AppendStereo(WaveStream stream, SpeechContexts contexts, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             return(AppendContexts(contexts));
         }
     }
     return(false);
 }
 public virtual SpeechEnroller.Result PostStereo(string filename, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(filename, channel))
         {
             return(Post());
         }
     }
     return(SpeechEnroller.Result.Invalid);
 }
Example #10
0
        public SpeechAudio(string filename, WaveFormat format, SpeechAudioChannel channel = SpeechAudioChannel.Mono)
        {
            FileName = Path.GetFileName(filename);
            Stream   = new WaveFileReader(filename);
            Channel  = channel;

            if (!Stream.WaveFormat.Equals(format))
            {
                Format   = format;
                Provider = new MediaFoundationResampler(Stream, format);
            }
        }
 public virtual bool AppendStereo(string filename, SpeechContexts contexts, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         var waveStream = new WaveFileReader(filename);
         if (AppendStereo(waveStream, channel))
         {
             return(AppendContexts(contexts));
         }
     }
     return(false);
 }
        public virtual bool AppendStereo(WaveStream stream, SpeechAudioChannel channel)
        {
            if (IsSessionOpen)
            {
                if (stream.CanSeek)
                {
                    stream.Seek(0, SeekOrigin.Begin);
                }

                Logger?.LogDebug("SpeechEnrollerBase.AppendStereo(): In-Channel: " + channel);
                Logger?.LogDebug("SpeechEnrollerBase.AppendStereo(): In-Length: " + stream.Length);
                Logger?.LogDebug("SpeechEnrollerBase.AppendStereo(): In-WaveFormat: " + stream.WaveFormat);

                SpeechAudio speechAudio;
                if (Codec == WaveFormatEncoding.Pcm)
                {
                    speechAudio = new SpeechAudio(stream, new WaveFormat(8000, 16, 2), channel);
                }
                else
                {
                    return(false);
                }

                Logger?.LogDebug("SpeechEnrollerBase.AppendStereo(): Append-Length: " + speechAudio.Stream.Length);
                Logger?.LogDebug("SpeechEnrollerBase.AppendStereo(): Append-WaveFormat: " + speechAudio.Stream.WaveFormat);

                speechAudio.FileName = BuildAudioName();

                switch (channel)
                {
                case SpeechAudioChannel.Mono:
                    Content.Add("data", speechAudio);
                    break;

                case SpeechAudioChannel.StereoLeft:
                    Content.Add("left", speechAudio);
                    break;

                case SpeechAudioChannel.StereoRight:
                    Content.Add("right", speechAudio);
                    break;
                }

                TotalSnippetsSent++;
                TotalAudioBytesSent += speechAudio.Stream.Length;

                return(true);
            }
            return(false);
        }
Example #13
0
 public Task <Result> PostStereoAsync(string filename, SpeechAudioChannel channel)
 {
     return(mSpeechEnroller.PostStereoAsync(filename, channel));
 }
 public Task<Result> PostStereoAsync(WaveStream stream, SpeechAudioChannel channel)
 {
     return mSpeechIdentifier.PostStereoAsync(stream, channel);
 }
Example #15
0
 public virtual Task <SpeechIdentifier.Result> PostStereoAsync(WaveStream stream, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             return(PostAsync());
         }
     }
     return(Task.FromResult(SpeechIdentifier.Result.Invalid));
 }
 public virtual SpeechVerifier.Result PostStereo(WaveStream stream, string languageCode, string livenessText, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             return(Post(languageCode, livenessText));
         }
     }
     return(SpeechVerifier.Result.Invalid);
 }
 public Task<Result> PostStereoAsync(string filename, SpeechAudioChannel channel)
 {
     return mSpeechIdentifier.PostStereoAsync(filename, channel);
 }
 public virtual void PostStereo(WaveStream stream, string languageCode, string livenessText, SpeechAudioChannel channel, SpeechVerifier.PostCallback callback)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             Post(languageCode, livenessText, callback);
         }
     }
 }
Example #19
0
 public Result PostStereo(string filename, SpeechAudioChannel channel)
 {
     return(mSpeechEnroller.PostStereo(filename, channel));
 }
 public bool AppendStereo(string filename, SpeechContexts contexts, SpeechAudioChannel channel)
 {
     return(mSpeechVerifier.AppendStereo(filename, contexts, channel));
 }
 public bool AppendStereo(WaveStream stream, SpeechAudioChannel channel)
 {
     return mSpeechIdentifier.AppendStereo(stream, channel);
 }
 public bool AppendStereo(string filename, SpeechAudioChannel channel)
 {
     return mSpeechIdentifier.AppendStereo(filename, channel);
 }
 public virtual Task <SpeechVerifier.Result> PostStereoAsync(WaveStream stream, string languageCode, string livenessText, SpeechAudioChannel channel)
 {
     if (IsSessionOpen)
     {
         if (AppendStereo(stream, channel))
         {
             return(PostAsync(languageCode, livenessText));
         }
     }
     return(Task.FromResult(SpeechVerifier.Result.Invalid));
 }
Example #24
0
 public Task <Result> PostStereoAsync(WaveStream stream, SpeechAudioChannel channel)
 {
     return(mSpeechEnroller.PostStereoAsync(stream, channel));
 }
Example #25
0
 public Result PostStereo(WaveStream stream, SpeechAudioChannel channel)
 {
     return(mSpeechEnroller.PostStereo(stream, channel));
 }
 public void PostStereo(string filename, SpeechAudioChannel channel, PostCallback callback)
 {
     mSpeechIdentifier.PostStereo(filename, channel, callback);
 }
 public Result PostStereo(string filename, SpeechAudioChannel channel)
 {
     return mSpeechIdentifier.PostStereo(filename, channel);
 }
 public void PostStereo(WaveStream stream, SpeechAudioChannel channel, PostCallback callback)
 {
     mSpeechIdentifier.PostStereo(stream, channel, callback);
 }
 public bool AppendStereo(WaveStream stream, SpeechContexts contexts, SpeechAudioChannel channel)
 {
     return(mSpeechVerifier.AppendStereo(stream, contexts, channel));
 }
 public Result PostStereo(WaveStream stream, SpeechAudioChannel channel)
 {
     return mSpeechIdentifier.PostStereo(stream, channel);
 }