SpeechDecoderStreamType Property |
Namespace: StreamCoders.Decoder
SpeechDecoder dec = new SpeechDecoder(); dec.Bitrate = 12200; dec.SetCodec(StreamCoders.Codec.AMRNB); dec.StreamType = StreamCoders.SpeechStreamType.StorageFormat; // It's using RFC 3267 bool initres = dec.Init(); if(initres == false) return; WaveOutput wout = new WaveOutput(); wout.BitsPerSample = 16; wout.Channels = 1; wout.SampleRate = 8000; wout.Init(); wout.OpenDevice(); FileStream ifs = new FileStream("file.amr", FileMode.Open); BinaryReader br = new BinaryReader(ifs); ifs.Position = 6; int bytesread = 0; bool eof = false; int packetMS = 20; int packetduration = 32; // 20ms in octets (AMR 12.2) byte[] buf = new byte[packetduration]; uint seq = 10; int ts = new System.Random(Environment.TickCount).Next(); while (!eof) { int startDuration = Environment.TickCount; bytesread = br.Read(buf, 0, packetduration); if (bytesread < packetduration) eof = true; byte[] samples = dec.Decode(buf); if (samples != null) { wout.Enqueue(samples); } } Console.WriteLine("done"); Console.ReadLine();