Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/analytics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ pub struct AnalyticsPayloadBuilder {
}

impl AnalyticsPayload {
pub fn new(event: impl Into<String>) -> AnalyticsPayloadBuilder {
pub fn builder(event: impl Into<String>) -> AnalyticsPayloadBuilder {
AnalyticsPayloadBuilder {
event: Some(event.into()),
props: HashMap::new(),
Expand Down Expand Up @@ -169,7 +169,7 @@ mod tests {
#[tokio::test]
async fn test_analytics() {
let client = AnalyticsClient::new(Some(""));
let payload = AnalyticsPayload::new("test_event")
let payload = AnalyticsPayload::builder("test_event")
.with("key1", "value1")
.with("key2", 2)
.build();
Expand Down
7 changes: 5 additions & 2 deletions crates/buffer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pub enum Error {
HTMLParseError(String),
}

type TextTransformation = Box<dyn Fn(&mut String)>;
type MdTransformation = Box<dyn Fn(&mut markdown::mdast::Node)>;

pub fn opinionated_md_to_html(text: impl AsRef<str>) -> Result<String, Error> {
let md = md_to_md(text)?;
let md_with_mentions = transform_mentions_in_markdown(&md);
Expand All @@ -23,7 +26,7 @@ pub fn opinionated_md_to_md(text: impl AsRef<str>) -> Result<String, Error> {
fn md_to_md(text: impl AsRef<str>) -> Result<String, Error> {
let mut text = text.as_ref().to_string();

let txt_transformations: Vec<Box<dyn Fn(&mut String)>> = vec![Box::new(remove_char_repeat)];
let txt_transformations: Vec<TextTransformation> = vec![Box::new(remove_char_repeat)];

for t in txt_transformations {
t(&mut text);
Expand All @@ -32,7 +35,7 @@ fn md_to_md(text: impl AsRef<str>) -> Result<String, Error> {
let mut ast = markdown::to_mdast(text.as_ref(), &markdown::ParseOptions::default())
.map_err(|e| Error::MarkdownParseError(e.to_string()))?;

let md_transformations: Vec<Box<dyn Fn(&mut markdown::mdast::Node)>> = vec![
let md_transformations: Vec<MdTransformation> = vec![
Box::new(remove_thematic_break),
Box::new(remove_empty_headings),
Box::new(|node| {
Expand Down
1 change: 1 addition & 0 deletions crates/llama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ impl Llama {
Ok((ctx, batch, last_index, progress_data_ptr, max_output_tokens))
}

#[allow(clippy::too_many_arguments)]
fn process_generation<'a>(
model: &LlamaModel,
mut ctx: llama_cpp_2::context::LlamaContext<'a>,
Expand Down
1 change: 1 addition & 0 deletions crates/vvad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ edition = "2021"

[dependencies]
earshot = { workspace = true }
thiserror = { workspace = true }
8 changes: 6 additions & 2 deletions crates/vvad/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
mod earshot_impl {
use earshot::VoiceActivityProfile;

#[derive(Debug, thiserror::Error)]
#[error("voice activity detection failed")]
pub struct VadError;

pub struct VoiceActivityDetector {
inner: earshot::VoiceActivityDetector,
}
Expand All @@ -12,8 +16,8 @@ mod earshot_impl {
}
}

pub fn predict_16khz(&mut self, samples: &[i16]) -> Result<bool, ()> {
self.inner.predict_16khz(samples).map_err(|_| ())
pub fn predict_16khz(&mut self, samples: &[i16]) -> Result<bool, VadError> {
self.inner.predict_16khz(samples).map_err(|_| VadError)
}
}

Expand Down
10 changes: 6 additions & 4 deletions crates/whisper-local/src/model/actual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ impl WhisperBuilder {
unsafe { Self::suppress_log() };

let context_param = {
let mut p = WhisperContextParameters::default();
p.gpu_device = 0;
p.use_gpu = true;
p.flash_attn = false; // crash on macos
let mut p = WhisperContextParameters {
gpu_device: 0,
use_gpu: true,
flash_attn: false, // crash on macos
..Default::default()
};
p.dtw_parameters.mode = whisper_rs::DtwMode::None;
p
};
Expand Down
2 changes: 1 addition & 1 deletion plugins/analytics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ mod test {
async fn test_analytics() {
let app = create_app(tauri::test::mock_builder());
let result = app
.event(hypr_analytics::AnalyticsPayload::new("test_event").build())
.event(hypr_analytics::AnalyticsPayload::builder("test_event").build())
.await;
assert!(result.is_ok());

Expand Down
4 changes: 2 additions & 2 deletions plugins/windows/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl AppWindow {
if self.label() == "main" {
use tauri_plugin_analytics::{AnalyticsPayload, AnalyticsPluginExt};

let e = AnalyticsPayload::new("show_main_window").build();
let e = AnalyticsPayload::builder("show_main_window").build();

let app_clone = app.clone();
tauri::async_runtime::spawn(async move {
Expand Down Expand Up @@ -173,7 +173,7 @@ impl WindowsPluginExt<tauri::Wry> for AppHandle<tauri::Wry> {
{
use tauri_plugin_analytics::{AnalyticsPayload, AnalyticsPluginExt};

let e = AnalyticsPayload::new(event_name)
let e = AnalyticsPayload::builder(event_name)
.with("user_id", user_id)
.with("session_id", session_id)
.build();
Expand Down