Skip to content

Commit

Permalink
feat: disable audio in app settings
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Aug 28, 2024
1 parent 890106c commit bf61694
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export function RecordingSettings({
audioDevices: localSettings.audioDevices,
usePiiRemoval: localSettings.usePiiRemoval,
restartInterval: localSettings.restartInterval,
disableAudio: localSettings.disableAudio,
};
console.log("Settings to update:", settingsToUpdate);
await updateSettings(settingsToUpdate);
Expand Down Expand Up @@ -205,6 +206,10 @@ export function RecordingSettings({
setLocalSettings({ ...localSettings, restartInterval: newValue });
};

const handleDisableAudioChange = (checked: boolean) => {
setLocalSettings({ ...localSettings, disableAudio: checked });
};

return (
<>
<div className="relative">
Expand Down Expand Up @@ -398,9 +403,6 @@ export function RecordingSettings({
<br />
before saving to the database or returning in search
results
<br />
this will avoid sending these information to openai
for example
</p>
</TooltipContent>
</Tooltip>
Expand Down Expand Up @@ -446,6 +448,35 @@ export function RecordingSettings({
/>
</div>

<div className="flex flex-col space-y-2">
<div className="flex items-center space-x-2">
<Switch
id="disableAudio"
checked={localSettings.disableAudio}
onCheckedChange={handleDisableAudioChange}
/>
<Label
htmlFor="disableAudio"
className="flex items-center space-x-2"
>
<span>disable audio recording</span>
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<HelpCircle className="h-4 w-4" />
</TooltipTrigger>
<TooltipContent>
<p>
useful if you don&apos;t need audio or if you have
memory/CPU issues
</p>
</TooltipContent>
</Tooltip>
</TooltipProvider>
</Label>
</div>
</div>

<div className="flex flex-col space-y-2">
<Button
onClick={handleUpdate}
Expand Down
5 changes: 5 additions & 0 deletions examples/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const defaultSettings: Settings = {
restartInterval: 0,
port: 3030,
dataDir: "default",
disableAudio: false,
};

export interface Settings {
Expand All @@ -54,6 +55,7 @@ export interface Settings {
restartInterval: number;
port: number;
dataDir: string;
disableAudio: boolean;
}

let store: Store | null = null;
Expand Down Expand Up @@ -125,6 +127,8 @@ export function useSettings() {
((await store!.get("restartInterval")) as number) || 0;
const savedPort = ((await store!.get("port")) as number) || 3030;
const savedDataDir = ((await store!.get("dataDir")) as string) || "";
const savedDisableAudio =
((await store!.get("disableAudio")) as boolean) || false;
setSettings({
openaiApiKey: savedKey,
useOllama: savedUseOllama,
Expand All @@ -143,6 +147,7 @@ export function useSettings() {
restartInterval: savedRestartInterval,
port: savedPort,
dataDir: savedDataDir,
disableAudio: savedDisableAudio,
});
} catch (error) {
console.error("Failed to load settings:", error);
Expand Down
2 changes: 1 addition & 1 deletion examples/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
version = "0.1.71"
version = "0.1.72"
description = ""
authors = ["you"]
license = ""
Expand Down
11 changes: 11 additions & 0 deletions examples/apps/screenpipe-app-tauri/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
.map_err(|e| e.to_string())?
.unwrap_or(String::from("default"));

let disable_audio = with_store(app.clone(), stores.clone(), path.clone(), |store| {
Ok(store
.get("disableAudio")
.and_then(|v| v.as_bool())
.unwrap_or(false))
})
.map_err(|e| e.to_string())?;

let port_str = port.to_string();
let mut args = vec!["--port", port_str.as_str()];
Expand Down Expand Up @@ -271,6 +278,10 @@ fn spawn_sidecar(app: &tauri::AppHandle) -> Result<CommandChild, String> {
}
}

if disable_audio {
args.push("--disable-audio");
}

// hardcode TESSDATA_PREFIX for windows
if cfg!(windows) {
let exe_dir = env::current_exe()
Expand Down

0 comments on commit bf61694

Please sign in to comment.