How to create an AI agent powered by your screen & mic
Screenpipe: A CLI/App for 24/7 Screen and Mic Recording, OCR, Transcription, and AI Integration
Screenpipe is a command-line interface (CLI) application that continuously records your screen and microphone activity, extracts Optical Character Recognition (OCR) data, generates transcriptions, and simplifies the process of feeding this data into AI models. Its flexible pipe system allows you to create powerful plugins that interact with captured screen and audio information. This example demonstrates building a simple pipe that leverages Ollama to analyze screen activity.
Prerequisites:
- Screenpipe installed and running.
- Bun installed (
npm install -g bun
). - Ollama installed with a model (DeepSeek-r1:1.5b is used in this example).
1. Pipe Creation:
Create a new Screenpipe pipe using the CLI:
bunx @screenpipe/create-pipe@latest
Follow the prompts to name your pipe (e.g., "my-activity-analyzer") and choose a directory.
2. Project Setup:
Open the project in your preferred editor (e.g., Cursor, VS Code):
cursor my-activity-analyzer
The initial project structure will include several files. For this example, remove unnecessary files:
rm -rf src/app/api/intelligence src/components/obsidian-settings.tsx src/components/file-suggest-textarea.tsx
3. Implementing the Analysis Cron Job:
Create src/app/api/analyze/route.ts
with the following code:
import { NextResponse } from "next/server"; import { pipe } from "@screenpipe/js"; import { streamText } from "ai"; import { ollama } from "ollama-ai-provider"; export async function POST(request: Request) { try { const { messages, model } = await request.json(); console.log("model:", model); const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000).toISOString(); const results = await pipe.queryScreenpipe({ startTime: fiveMinutesAgo, limit: 10, contentType: "all", }); const provider = ollama(model); const result = streamText({ model: provider, messages: [ ...messages, { role: "user", content: `Analyze this activity data and summarize what I've been doing: ${JSON.stringify(results)}`, }, ], }); return result.toDataStreamResponse(); } catch (error) { console.error("error:", error); return NextResponse.json({ error: "Failed to analyze activity" }, { status: 500 }); } }
4. pipe.json
Configuration for Scheduling:
Create or modify pipe.json
to include the cron job:
{ "crons": [ { "path": "/api/analyze", "schedule": "*/5 * * * *" // Runs every 5 minutes } ] }
5. Updating the Main Page (src/app/page.tsx
):
"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { OllamaModelsList } from "@/components/ollama-models-list"; import { Label } from "@/components/ui/label"; import { useChat } from "ai/react"; export default function Home() { const [selectedModel, setSelectedModel] = useState("deepseek-r1:1.5b"); const { messages, input, handleInputChange, handleSubmit } = useChat({ body: { model: selectedModel }, api: "/api/analyze", }); return ( <main className="p-4 max-w-2xl mx-auto space-y-4"> <div className="space-y-2"> <label htmlFor="model">Ollama Model</label> <OllamaModelsList defaultValue={selectedModel} onChange={setSelectedModel} /> </div> <div> {messages.map((message) => ( <div key={message.id}> <div>{message.role === "user" ? "User: " : "AI: "}</div> <div>{message.content}</div> </div> ))} </div> </main> ); }
6. Local Testing:
Run the pipe locally:
bun i // or npm install bun dev
Access the application at http://localhost:3000
.
7. Screenpipe Installation:
Install the pipe into Screenpipe:
- UI: Open the Screenpipe app, navigate to the Pipes section, click " ", and provide the local path to your pipe.
- CLI:
screenpipe install /path/to/my-activity-analyzer screenpipe enable my-activity-analyzer
Copy after loginHow it Works:
-
Data Querying:
pipe.queryScreenpipe()
retrieves recent screen and audio data. - AI Processing: Ollama analyzes the data using a prompt.
- UI: A simple interface displays the analysis results.
- Scheduling: Screenpipe's cron job executes the analysis every 5 minutes.
Next Steps:
- Add configuration options.
- Integrate with external services.
- Implement more sophisticated UI components.
References:
- Screenpipe documentation.
- Example Screenpipe pipes.
- Screenpipe SDK reference.
The above is the detailed content of How to create an AI agent powered by your screen & mic. For more information, please follow other related articles on the PHP Chinese website!
-
Data Querying:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

I built a functional multi-tenant SaaS application (an EdTech app) with your everyday tech tool and you can do the same. First, what’s a multi-tenant SaaS application? Multi-tenant SaaS applications let you serve multiple customers from a sing
