#voicevox #load #dynamically #download #run-time #dyn #voice-vox

voicevox-dyn

dynamically load and run voicevox from rust

3 releases (breaking)

0.3.0 Oct 13, 2023
0.2.0 Oct 13, 2023
0.1.0 Sep 18, 2023

#679 in Audio

MIT license

15KB
271 lines

voicevox without hassle

Downloads VOICEVOX CORE and dynamically loads it at runtime.

This crate makes it as easy as possible to use voicevox in rust, in particular, it is possible to distribute a single binary that sets up voicevox itself and is also able to run it.

Example

use voicevox_dyn::{AccelerationMode, VoiceVox};

const SPEAKER_ID: u32 = 4;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let threads = std::thread::available_parallelism()?.get() as u16;

    let mut vv = VoiceVox::load()?;
    vv.init(AccelerationMode::Auto, threads, false)?;
    vv.load_model(SPEAKER_ID)?;

    let wav = vv.tts("こんにちは", SPEAKER_ID, Default::default())?;

    std::fs::write("audio.wav", wav.as_slice())?;

    Ok(())
}

Alternatives

If you prefer to dynamically link voicevox instead, I recommend using vvcore.


lib.rs:

VoiceVox without hassle

Downloads VOICEVOX CORE and dynamically loads it at runtime.

The intent of this crate is to make using voicevox as easy as possible and in particular making it easy to distribute a single binary that sets up voicevox itself and is also able to run it.

Alternatives

If you prefer to dynamically link voicevox instead, I recommend using vvcore.

Dependencies

~7–13MB
~159K SLoC