frontend fixes & db rewrite with serde
This commit is contained in:
parent
61b7a79455
commit
091a41ac33
37 changed files with 910 additions and 663 deletions
|
|
@ -1,33 +1,20 @@
|
|||
use pv_recorder::RecorderBuilder;
|
||||
use jarvis_core::recorder;
|
||||
// use rodio::{Decoder, OutputStream, Sink};
|
||||
use std::path::PathBuf;
|
||||
use jarvis_core::audio;
|
||||
|
||||
#[tauri::command]
|
||||
pub fn pv_get_audio_devices() -> Vec<String> {
|
||||
let audio_devices = RecorderBuilder::default().get_audio_devices();
|
||||
match audio_devices {
|
||||
Ok(audio_devices) => audio_devices,
|
||||
Err(err) => panic!("Failed to get audio devices: {}", err),
|
||||
}
|
||||
recorder::get_audio_devices()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn pv_get_audio_device_name(idx: i32) -> String {
|
||||
let audio_devices = RecorderBuilder::default().get_audio_devices();
|
||||
let mut first_device: String = String::new();
|
||||
match audio_devices {
|
||||
Ok(audio_devices) => {
|
||||
for (_idx, device) in audio_devices.iter().enumerate() {
|
||||
if idx as usize == _idx {
|
||||
return device.to_string();
|
||||
}
|
||||
|
||||
if _idx == 0 {
|
||||
first_device = device.to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => panic!("Failed to get audio devices: {}", err),
|
||||
};
|
||||
|
||||
// return first device as default, if none were matched
|
||||
first_device
|
||||
recorder::get_audio_device_name(idx)
|
||||
}
|
||||
|
||||
#[tauri::command(async)]
|
||||
pub fn play_sound(filename: &str) {
|
||||
let path = PathBuf::from(filename);
|
||||
audio::play_sound(&path);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue