Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

feat: return device type & name in audio results

Louis Beaumontaefc2769dc98
diff --git a/screenpipe-audio/src/core.rs b/screenpipe-audio/src/core.rs
index a2346be30..77e9e4279 100644
--- a/screenpipe-audio/src/core.rs
+++ b/screenpipe-audio/src/core.rs
@@ -4,7 +4,7 @@ use chrono::Utc;
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use cpal::StreamError;
use log::{debug, error, info, warn};
-use serde::Serialize;
+use serde::{Deserialize, Serialize};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
@@ -41,7 +41,7 @@ pub struct DeviceControl {
pub is_paused: bool,
}
-#[derive(Clone, Eq, PartialEq, Hash, Serialize, Debug)]
+#[derive(Clone, Eq, PartialEq, Hash, Serialize, Debug, Deserialize)]
pub enum DeviceType {
Input,
Output,
diff --git a/screenpipe-server/src/db.rs b/screenpipe-server/src/db.rs
index c18ad7201..efebcda41 100644
--- a/screenpipe-server/src/db.rs
+++ b/screenpipe-server/src/db.rs
@@ -111,6 +111,8 @@ struct AudioResultRaw {
offset_index: i64,
transcription_engine: String,
tags: Option<String>,
+ device_name: String,
+ is_input_device: bool,
}
#[derive(Debug, Serialize, Deserialize)]
@@ -122,6 +124,8 @@ pub struct AudioResult {
pub offset_index: i64,
pub transcription_engine: String,
pub tags: Vec<String>,
+ pub device_name: String,
+ pub device_type: DeviceType,
}
#[derive(Debug, Deserialize, PartialEq)]
@@ -721,7 +725,9 @@ impl DatabaseManager {
audio_chunks.file_path,
audio_transcriptions.offset_index,
audio_transcriptions.transcription_engine,
- GROUP_CONCAT(tags.name, ',') as tags
+ GROUP_CONCAT(tags.name, ',') as tags,
+ audio_transcriptions.device as device_name,
+ audio_transcriptions.is_input_device
FROM
audio_transcriptions
JOIN
@@ -799,6 +805,12 @@ impl DatabaseManager {
.tags
.map(|s| s.split(',').map(String::from).collect())
.unwrap_or_default(),
+ device_name: raw.device_name,
+ device_type: if raw.is_input_device {
+ DeviceType::Input
+ } else {
+ DeviceType::Output
+ },
})
.collect();
diff --git a/screenpipe-server/src/server.rs b/screenpipe-server/src/server.rs
index e8bbe9618..7388219bf 100644
--- a/screenpipe-server/src/server.rs
+++ b/screenpipe-server/src/server.rs
@@ -21,6 +21,7 @@ use chrono::{DateTime, Utc};
use log::{debug, error, info};
use screenpipe_audio::{
default_input_device, default_output_device, list_audio_devices, AudioDevice, DeviceControl,
+ DeviceType,
};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
@@ -131,6 +132,8 @@ pub struct AudioContent {
pub file_path: String,
pub offset_index: i64,
pub tags: Vec<String>,
+ pub device_name: String,
+ pub device_type: DeviceType,
}
#[derive(Serialize, Deserialize, Debug)]
@@ -282,6 +285,8 @@ pub(crate) async fn search(
file_path: audio.file_path.clone(),
offset_index: audio.offset_index,
tags: audio.tags.clone(),
+ device_name: audio.device_name.clone(),
+ device_type: audio.device_type.clone(),
}),
SearchResult::FTS(fts) => ContentItem::FTS(FTSContent {
text_id: fts.text_id,