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); }
public virtual bool Append(WaveStream stream) { if (IsSessionOpen) { if (stream.CanSeek) { stream.Seek(0, SeekOrigin.Begin); } Logger?.LogDebug("SpeechEnrollerBase.Append(): In-Length: " + stream.Length); Logger?.LogDebug("SpeechEnrollerBase.Append(): In-WaveFormat: " + stream.WaveFormat); SpeechAudio speechAudio; if (Codec == WaveFormatEncoding.ALaw) { speechAudio = new SpeechAudio(stream, WaveFormat.CreateALawFormat(8000, 1)); } else if (Codec == WaveFormatEncoding.Pcm) { speechAudio = new SpeechAudio(stream, new WaveFormat(8000, 16, 1)); } else { return(false); } Logger?.LogDebug("SpeechEnrollerBase.Append(): Append-Length: " + speechAudio.Stream.Length); Logger?.LogDebug("SpeechEnrollerBase.Append(): Append-WaveFormat: " + speechAudio.Stream.WaveFormat); speechAudio.FileName = BuildAudioName(); Content.Add("data", speechAudio); TotalSnippetsSent++; TotalAudioBytesSent += speechAudio.Stream.Length; return(true); } return(false); }