Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created May 15, 2016 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuka1984/65b8b372afde9035db5231fb575b4452 to your computer and use it in GitHub Desktop.
Save yuka1984/65b8b372afde9035db5231fb575b4452 to your computer and use it in GitHub Desktop.
[TestFixture]
public class SpeakerTest
{
private IVoiceCapture _capture;
private IVoiceSpeaker _speaker;
[SetUp]
public void Setup()
{
_capture = new VoiceCapture(8000, 250);
_speaker = new VoiceSpeaker(8000);
}
[TearDown]
public void Tear()
{
_capture.Dispose();
}
[Test]
public void NSpeexTest()
{
var encoder = new EncodeSubject(BandMode.Narrow);
var decoder = new DecodeSubject(BandMode.Narrow);
var _stopwatch = Stopwatch.StartNew();
_capture.Subscribe(b =>
{
var time = _stopwatch.ElapsedMilliseconds;
Debug.WriteLine($"{time}msec PCM {b.Length}");
});
_capture.Subscribe(encoder);
encoder.Subscribe(b =>
{
var time = _stopwatch.ElapsedMilliseconds;
Debug.WriteLine($"{time}msec eSPX {b.Length}");
});
encoder.Subscribe(decoder);
decoder.Subscribe(b =>
{
var time = _stopwatch.ElapsedMilliseconds;
Debug.WriteLine($"{time}msec dSPX {b.Length}");
});
decoder.Delay(TimeSpan.FromMilliseconds(1000)).Subscribe(_speaker);
_capture.Start();
Thread.Sleep(5000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment