move audio toolkit into src-tauri to fix permissions
This commit is contained in:
parent
0c927d2a70
commit
59541b8ec4
19 changed files with 105 additions and 7736 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -23,7 +23,5 @@ dist-ssr
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
src-tauri/resources/models
|
|
||||||
|
|
||||||
/target/
|
/target/
|
||||||
recording_*
|
recording_*
|
||||||
|
|
|
||||||
7696
Cargo.lock
generated
7696
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,3 +0,0 @@
|
||||||
[workspace]
|
|
||||||
members = ["src-tauri", "crates/audio-toolkit"]
|
|
||||||
resolver = "2"
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "audio-toolkit"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2024"
|
|
||||||
description = "Audio recording and processing toolkit for Handy"
|
|
||||||
authors = ["cjpais"]
|
|
||||||
|
|
||||||
[[bin]]
|
|
||||||
name = "cli"
|
|
||||||
path = "src/bin/cli.rs"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
anyhow = "1.0.98"
|
|
||||||
cpal = "0.16.0"
|
|
||||||
hound = "3.5.1"
|
|
||||||
rubato = "0.16.2"
|
|
||||||
vad-rs = "0.1.5"
|
|
||||||
|
|
||||||
[dependencies.ort-sys]
|
|
||||||
version = "=2.0.0-rc.9"
|
|
||||||
89
src-tauri/Cargo.lock
generated
89
src-tauri/Cargo.lock
generated
|
|
@ -895,6 +895,20 @@ dependencies = [
|
||||||
"coreaudio-sys",
|
"coreaudio-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "coreaudio-rs"
|
||||||
|
version = "0.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1aae284fbaf7d27aa0e292f7677dfbe26503b0d555026f702940805a630eac17"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 1.3.2",
|
||||||
|
"libc",
|
||||||
|
"objc2-audio-toolbox",
|
||||||
|
"objc2-core-audio",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "coreaudio-sys"
|
name = "coreaudio-sys"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
|
@ -912,7 +926,7 @@ checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alsa",
|
"alsa",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
"coreaudio-rs",
|
"coreaudio-rs 0.11.3",
|
||||||
"dasp_sample",
|
"dasp_sample",
|
||||||
"jni",
|
"jni",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
|
@ -927,6 +941,32 @@ dependencies = [
|
||||||
"windows 0.54.0",
|
"windows 0.54.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpal"
|
||||||
|
version = "0.16.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbd307f43cc2a697e2d1f8bc7a1d824b5269e052209e28883e5bc04d095aaa3f"
|
||||||
|
dependencies = [
|
||||||
|
"alsa",
|
||||||
|
"coreaudio-rs 0.13.0",
|
||||||
|
"dasp_sample",
|
||||||
|
"jni",
|
||||||
|
"js-sys",
|
||||||
|
"libc",
|
||||||
|
"mach2",
|
||||||
|
"ndk 0.9.0",
|
||||||
|
"ndk-context",
|
||||||
|
"num-derive",
|
||||||
|
"num-traits",
|
||||||
|
"objc2-audio-toolbox",
|
||||||
|
"objc2-core-audio",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
"windows 0.54.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
|
|
@ -2029,12 +2069,14 @@ name = "handy"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cpal",
|
"cpal 0.16.0",
|
||||||
"enigo",
|
"enigo",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"hound",
|
||||||
"log",
|
"log",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
"ort-sys",
|
||||||
"rdev",
|
"rdev",
|
||||||
"reqwest 0.11.27",
|
"reqwest 0.11.27",
|
||||||
"rodio",
|
"rodio",
|
||||||
|
|
@ -3268,6 +3310,21 @@ dependencies = [
|
||||||
"objc2-quartz-core 0.3.1",
|
"objc2-quartz-core 0.3.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-audio-toolbox"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "10cbe18d879e20a4aea544f8befe38bcf52255eb63d3f23eca2842f3319e4c07"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.8.0",
|
||||||
|
"libc",
|
||||||
|
"objc2 0.6.1",
|
||||||
|
"objc2-core-audio",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
"objc2-foundation 0.3.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-cloud-kit"
|
name = "objc2-cloud-kit"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
|
|
@ -3279,6 +3336,28 @@ dependencies = [
|
||||||
"objc2-foundation 0.3.1",
|
"objc2-foundation 0.3.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-core-audio"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ca44961e888e19313b808f23497073e3f6b3c22bb485056674c8b49f3b025c82"
|
||||||
|
dependencies = [
|
||||||
|
"dispatch2",
|
||||||
|
"objc2 0.6.1",
|
||||||
|
"objc2-core-audio-types",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "objc2-core-audio-types"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c0f1cc99bb07ad2ddb6527ddf83db6a15271bb036b3eb94b801cd44fdc666ee1"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.8.0",
|
||||||
|
"objc2 0.6.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "objc2-core-data"
|
name = "objc2-core-data"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
|
|
@ -4405,7 +4484,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1"
|
checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"claxon",
|
"claxon",
|
||||||
"cpal",
|
"cpal 0.15.3",
|
||||||
"hound",
|
"hound",
|
||||||
"lewton",
|
"lewton",
|
||||||
"symphonia",
|
"symphonia",
|
||||||
|
|
@ -4413,9 +4492,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rubato"
|
name = "rubato"
|
||||||
version = "0.16.1"
|
version = "0.16.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cdd96992d7e24b3d7f35fdfe02af037a356ac90d41b466945cf3333525a86eea"
|
checksum = "5258099699851cfd0082aeb645feb9c084d9a5e1f1b8d5372086b989fc5e56a1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-complex",
|
"num-complex",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ description = "Handy"
|
||||||
authors = ["cjpais"]
|
authors = ["cjpais"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
default-run = "handy"
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
incremental = true # Compile your binary in smaller steps.
|
incremental = true # Compile your binary in smaller steps.
|
||||||
|
|
@ -18,6 +19,10 @@ incremental = true # Compile your binary in smaller steps.
|
||||||
name = "handy_app_lib"
|
name = "handy_app_lib"
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
|
# [[bin]]
|
||||||
|
# name = "cli"
|
||||||
|
# path = "src/audio_toolkit/bin/cli.rs"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
tauri-build = { version = "2", features = [] }
|
tauri-build = { version = "2", features = [] }
|
||||||
|
|
||||||
|
|
@ -30,10 +35,11 @@ serde_json = "1"
|
||||||
tauri-plugin-clipboard-manager = "2"
|
tauri-plugin-clipboard-manager = "2"
|
||||||
tauri-plugin-macos-permissions = "2.0.4"
|
tauri-plugin-macos-permissions = "2.0.4"
|
||||||
rdev = { git = "https://github.com/rustdesk-org/rdev" }
|
rdev = { git = "https://github.com/rustdesk-org/rdev" }
|
||||||
cpal = "0.15.3"
|
cpal = "0.16.0"
|
||||||
whisper-rs = { version = "0.13.2", features = ["whisper-cpp-log"] }
|
whisper-rs = { version = "0.13.2", features = ["whisper-cpp-log"] }
|
||||||
anyhow = "1.0.95"
|
anyhow = "1.0.95"
|
||||||
rubato = "0.16.1"
|
rubato = "0.16.2"
|
||||||
|
hound = "3.5.1"
|
||||||
env_logger = "0.11.6"
|
env_logger = "0.11.6"
|
||||||
log = "0.4.25"
|
log = "0.4.25"
|
||||||
tokio = "1.43.0"
|
tokio = "1.43.0"
|
||||||
|
|
@ -45,7 +51,6 @@ tauri-plugin-process = "2"
|
||||||
rodio = "0.20.1"
|
rodio = "0.20.1"
|
||||||
reqwest = { version = "0.11", features = ["json", "stream"] }
|
reqwest = { version = "0.11", features = ["json", "stream"] }
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
audio-toolkit = { path = "../crates/audio-toolkit" }
|
|
||||||
|
|
||||||
[dependencies.ort-sys]
|
[dependencies.ort-sys]
|
||||||
version = "=2.0.0-rc.9"
|
version = "=2.0.0-rc.9"
|
||||||
|
|
|
||||||
BIN
src-tauri/resources/models/silero_vad_v4.onnx
Normal file
BIN
src-tauri/resources/models/silero_vad_v4.onnx
Normal file
Binary file not shown.
|
|
@ -9,7 +9,7 @@ use cpal::{
|
||||||
traits::{DeviceTrait, HostTrait, StreamTrait},
|
traits::{DeviceTrait, HostTrait, StreamTrait},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::audio_toolkit::{
|
||||||
VoiceActivityDetector,
|
VoiceActivityDetector,
|
||||||
audio::FrameResampler,
|
audio::FrameResampler,
|
||||||
constants,
|
constants,
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
use audio_toolkit::{AudioRecorder, SileroVad, list_input_devices, vad::SmoothedVad};
|
|
||||||
use hound::WavWriter;
|
use hound::WavWriter;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
|
||||||
|
use handy_app_lib::audio_toolkit::{
|
||||||
|
audio::{list_input_devices, CpalDeviceInfo},
|
||||||
|
vad::SmoothedVad,
|
||||||
|
AudioRecorder, SileroVad,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
enum RecorderMode {
|
enum RecorderMode {
|
||||||
AlwaysOn,
|
AlwaysOn,
|
||||||
|
|
@ -73,7 +78,7 @@ impl RecorderState {
|
||||||
fn start_recording(
|
fn start_recording(
|
||||||
&mut self,
|
&mut self,
|
||||||
device_index: Option<usize>,
|
device_index: Option<usize>,
|
||||||
devices: &[audio_toolkit::CpalDeviceInfo],
|
devices: &[CpalDeviceInfo],
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
if self.is_recording {
|
if self.is_recording {
|
||||||
return Err("Already recording! Stop the current recording first.".into());
|
return Err("Already recording! Stop the current recording first.".into());
|
||||||
|
|
@ -170,7 +175,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
println!("=========================");
|
println!("=========================");
|
||||||
print_help();
|
print_help();
|
||||||
|
|
||||||
let silero = SileroVad::new("./src-tauri/resources/models/silero_vad_v4.onnx", 0.5)?;
|
let silero = SileroVad::new("./resources/models/silero_vad_v4.onnx", 0.5)?;
|
||||||
let smoothed_vad = SmoothedVad::new(Box::new(silero), 15, 15);
|
let smoothed_vad = SmoothedVad::new(Box::new(silero), 15, 15);
|
||||||
let recorder = AudioRecorder::new()?.with_vad(Box::new(smoothed_vad));
|
let recorder = AudioRecorder::new()?.with_vad(Box::new(smoothed_vad));
|
||||||
let mut state = RecorderState::new(recorder);
|
let mut state = RecorderState::new(recorder);
|
||||||
|
|
@ -324,7 +329,7 @@ fn print_help() {
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_devices(devices: &[audio_toolkit::CpalDeviceInfo]) {
|
fn print_devices(devices: &[CpalDeviceInfo]) {
|
||||||
println!("Available audio devices:");
|
println!("Available audio devices:");
|
||||||
for (index, device) in devices.iter().enumerate() {
|
for (index, device) in devices.iter().enumerate() {
|
||||||
println!(" {}: {}", index, device.name);
|
println!(" {}: {}", index, device.name);
|
||||||
|
|
@ -4,7 +4,7 @@ use std::path::Path;
|
||||||
use vad_rs::Vad;
|
use vad_rs::Vad;
|
||||||
|
|
||||||
use super::{VadFrame, VoiceActivityDetector};
|
use super::{VadFrame, VoiceActivityDetector};
|
||||||
use crate::constants;
|
use crate::audio_toolkit::constants;
|
||||||
|
|
||||||
const SILERO_FRAME_MS: u32 = 30;
|
const SILERO_FRAME_MS: u32 = 30;
|
||||||
const SILERO_FRAME_SAMPLES: usize =
|
const SILERO_FRAME_SAMPLES: usize =
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
mod actions;
|
mod actions;
|
||||||
|
pub mod audio_toolkit;
|
||||||
mod commands;
|
mod commands;
|
||||||
mod managers;
|
mod managers;
|
||||||
mod settings;
|
mod settings;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::settings::get_settings;
|
use crate::settings::get_settings;
|
||||||
use audio_toolkit::{vad::SmoothedVad, AudioRecorder, SileroVad};
|
use crate::audio_toolkit::{vad::SmoothedVad, AudioRecorder, SileroVad};
|
||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue