blob: df3891e3b640d156123084b2c0514718c70b890c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
extern crate byteorder;
extern crate libcodec2;
use byteorder::{LittleEndian, ReadBytesExt};
use std::fs::File;
use std::io::prelude::*;
use std::io::Cursor;
use std::path::Path;
fn main() {
let path = Path::new("../../codec2/wav/cross.wav");
let mut file = File::open(&path).unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).unwrap();
let mut rdr = Cursor::new(buf);
let mut speech = Vec::new();
while let Ok(i) = rdr.read_i16::<LittleEndian>() {
speech.push(i);
}
let mut bits = Vec::new();
let c = libcodec2::Codec2::new();
c.encode(&speech, &mut bits);
println!("{:?}", bits);
}
|