Crates.io | ogg-opus-wasm |
lib.rs | ogg-opus-wasm |
version | 0.1.3 |
source | src |
created_at | 2023-10-04 02:27:02.22638 |
updated_at | 2023-10-04 07:07:56.962276 |
description | A decoder/encoder for Ogg Opus for WASM |
homepage | |
repository | https://github.com/kujirahand/ogg-opus-wasm |
max_upload_size | |
id | 991754 |
size | 24,703 |
A encoder for Ogg Opus in Rust for WASM.
We are currently investigating this issue.
Uncaught TypeError: Failed to resolve module specifier "env". Relative references must start with either "/", "./", or "../".
cargo add ogg-opus-wasm
wasm-pack build --target web
This example makes use of wav
crate, you can use it adding to your cargo.toml
file:
wav = "^1.0"
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();
let mut f = File::open("my_file.ogg").unwrap();
let (raw, header) = ogg_opus::decode::<_,16000>(f).unwrap();
use std::io::Cursor;
// Let's say this vec contains Ogg Opus data
let opus: Vec<u8> = Vec::new();
let (raw, header) = ogg_opus::decode::<_,16000>(Cursor::new(opus)).unwrap();
i16
(integer of 16 bits) for the raw part.