A decoder/encoder for Ogg Opus in Rust
Add to your cargo.toml
toml
ogg-opus = "^0.1"
Since we use const generics
, the minimum version of Rust is 1.51
This example makes use of wav
crate, you can use it adding to your cargo.toml
file:
toml
wav = "^1.0"
rust
let mut f = File::open("my_file.wav").unwrap();
let (_, b) = wav::read(&mut f).unwrap();
let audio = b.try_into_sixteen().unwrap();
let opus = ogg_opus::encode::<16000, 1>(&audio).unwrap();
rust
let mut f = File::open("my_file.ogg").unwrap();
let (raw, header) = ogg_opus::decode::<_,16000>(f).unwrap();
```rust use std::io::Cursor;
// Let's say this vec contains Ogg Opus data
let opus: Vec
i16
(integer of 16 bits) for the raw part.