Skip to content

Instantly share code, notes, and snippets.

@yuka1984
Created May 15, 2016 12:47
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/de25c7396611186ea3a203ff5ad4a4dc to your computer and use it in GitHub Desktop.
Save yuka1984/de25c7396611186ea3a203ff5ad4a4dc to your computer and use it in GitHub Desktop.
[TestFixture]
public class SpeakerTest
{
private IVoiceCapture _capture;
private IVoiceSpeaker _speaker;
[SetUp]
public void Setup()
{
// サンプルレート8000にて16bits/1channelで250msec毎にデータを受け取る。
_capture = new VoiceCapture(8000, 250);
// サンプルレート8000にて16bits/1channelの音声データを再生する。
_speaker = new VoiceSpeaker(8000);
}
[TearDown]
public void Tear()
{
_capture.Dispose();
}
[Test]
public void CaptureSpeakerTest()
{
var _stopwatch = Stopwatch.StartNew();
_capture.Subscribe(b =>
{
var time = _stopwatch.ElapsedMilliseconds;
var bs = string.Join("-", b.Select(x => x.ToString("x2")));
Console.WriteLine(bs);
Debug.WriteLine($"{time} {b.Length} {bs}");
});
// キャプチャーしたデータを1000msecディレイして再生する。
_capture.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