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

Add new feature (#1484)

Meng Zhangfb90573405a1
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index a24cc409f..3812d5fc6 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -531,11 +531,16 @@ async fn process_audio_result(
return Ok(Some(audio_chunk_id));
}
+ let offset_index = db
+ .count_audio_transcriptions(audio_chunk_id)
+ .await
+ .unwrap_or(0);
+
if let Err(e) = db
.insert_audio_transcription(
audio_chunk_id,
&transcription,
- 0,
+ offset_index,
&transcription_engine,
&result.input.device,
Some(speaker.id),
diff --git a/screenpipe-server/src/db.rs b/screenpipe-server/src/db.rs
index 3ece39499..097991849 100644
--- a/screenpipe-server/src/db.rs
+++ b/screenpipe-server/src/db.rs
@@ -123,6 +123,16 @@ impl DatabaseManager {
Ok(id)
}
+ pub async fn count_audio_transcriptions(&self, audio_chunk_id: i64) -> Result<i64, sqlx::Error> {
+ let count = sqlx::query_scalar::<_, i64>(
+ "SELECT COUNT(*) FROM audio_transcriptions WHERE audio_chunk_id = ?1"
+ )
+ .bind(audio_chunk_id)
+ .fetch_one(&self.pool)
+ .await?;
+ Ok(count)
+ }
+
#[allow(clippy::too_many_arguments)]
pub async fn insert_audio_transcription(
&self,