https://github.com/vbrazo/electron-audio-shot
A cross-platform audio capture library for Electron apps with platform-specific permission handling
https://github.com/vbrazo/electron-audio-shot
Last synced: 11 months ago
JSON representation
A cross-platform audio capture library for Electron apps with platform-specific permission handling
- Host: GitHub
- URL: https://github.com/vbrazo/electron-audio-shot
- Owner: vbrazo
- License: mit
- Created: 2025-07-08T07:40:15.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-08T15:45:34.000Z (11 months ago)
- Last Synced: 2025-07-08T15:53:07.335Z (11 months ago)
- Language: TypeScript
- Size: 115 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# electron-audio-shot
A **completely generic, production-ready npm library** for Electron apps that enables cross-platform audio capture, permission handling, echo cancellation, and screenshot capture capabilities โ with full TypeScript and React support.
---
## ๐ฏ What We've Created
A **universal, drop-in audio + screenshot solution** for any Electron app.
---
## ๐ฆ Features
- โ
Cross-platform audio capture (macOS, Windows, Linux)
- โ
Platform-specific permission handling
- โ
Echo cancellation + real-time processing
- โ
Screenshot capture (manual + automatic)
- โ
TypeScript support with full type definitions
- โ
React components for easy integration
- โ
Comprehensive testing & docs
- โ
Zero app-specific dependencies
---
## ๐ ๏ธ Installation
```bash
npm install electron-audio-shot
```
> โ ๏ธ Requires `electron >= 20.0.0` as a peer dependency.
---
## ๐๏ธ Architecture
```
electron-audio-shot/
โโโ src/
โ โโโ main/ # Main process services
โ โโโ renderer/ # Renderer process services
โ โโโ components/ # React components
โ โโโ types/ # Type definitions
โ โโโ constants/ # Shared constants
โ โโโ index.ts # Entry point
โโโ examples/ # Integration examples
โโโ integration-tests/ # Integration tests
โโโ test-runner.ts # Custom test runner
โโโ README.md # This file
```
---
## ๐ Platform Support
| Feature | macOS | Windows | Linux |
|------------------|----------------|----------------|----------------|
| System Audio | โ
Native | โ
Loopback | โ ๏ธ Limited |
| Microphone | โ
Native | โ
Native | โ
Native |
| Echo Cancellation| โ
Advanced | โ
Real-time | โ ๏ธ Basic |
| Screenshots | โ
Native | โ
Electron | โ
Electron |
| Permissions | System Prefs | Browser | Browser |
---
## โ๏ธ Quick Start
### Main Process
```ts
import { audioScreenshotService } from 'electron-audio-shot';
const service = new audioScreenshotService({
sampleRate: 24000,
chunkDuration: 0.1,
enableEchoCancellation: true,
});
service.setupIpcHandlers();
```
### Renderer Process
```ts
import { PlatformAudioCapture } from 'electron-audio-shot';
const audioCapture = new PlatformAudioCapture();
await audioCapture.startCapture(5, 'medium'); // Start recording
const result = await audioCapture.stopCapture(); // Stop and retrieve chunks
```
---
## ๐ป React Example
```tsx
import { useState } from 'react';
import {
PlatformAudioCapture,
PlatformPermissionChecker
} from 'electron-audio-shot';
export function AudioRecorder() {
const [isRecording, setIsRecording] = useState(false);
const audioCapture = new PlatformAudioCapture();
return (
console.log('Ready')}
onPermissionsError={(err) => console.error(err)}
/>
{
const res = await audioCapture.startCapture(5, 'medium');
if (res.success) setIsRecording(true);
}}>
Start Recording
);
}
```
---
## ๐ API Reference
### `audioScreenshotService` (Main)
```ts
new audioScreenshotService(config)
setupIpcHandlers()
startAudioCapture()
stopAudioCapture()
captureScreenshot()
getPlatform()
getConfig()
updateConfig(partialConfig)
```
### `PlatformAudioCapture` (Renderer)
```ts
new PlatformAudioCapture()
startCapture(interval, quality)
stopCapture()
captureManualScreenshot(quality)
getState()
onAudioChunk(cb)
```
### React Components
```tsx
{}}
onPermissionsError={(err) => {}}
/>
{}}
onError={(err) => {}}
/>
```
---
## ๐งช Testing
```bash
npm run test:basic # Basic structure
npm run test:integration # Platform flows
npm test # All tests
```
Platform testing instructions included in inline comments.
---
## ๐ Performance
| Metric | Value |
|--------------------|--------------------------------------------|
| Audio Latency | < 50ms |
| Sample Rate | 24kHz (configurable) |
| Screenshot Sizes | Low (~100KB), Medium (~300KB), High (~1MB) |
| Memory Use | <10MB typical |
---
## ๐ฏ Use Cases
- ๐๏ธ Voice memo apps
- ๐ง AI assistants with context
- ๐ฅ Screen/audio recorders
- ๐
Meeting note-takers
---
## ๐ง Advanced Usage
### Real-time Streaming
```ts
audioCapture.onAudioChunk(chunk => streamToServer(chunk));
```
### Manual Screenshot
```ts
await audioCapture.captureManualScreenshot('high');
```
---
## ๐ค Contributing
```bash
git clone https://github.com/vbrazo/electron-audio-shot
cd electron-audio-shot
npm install
npm run build
npm test
```
- Fork โ Feature branch โ PR with tests.
---
## ๐ License
MIT ยฉ Vitor Oliveira
---
## ๐ฎ Future Enhancements
- ๐ด Video capture
- โ๏ธ Cloud upload
- ๐ WebRTC integration
- ๐๏ธ Advanced filters
- ๐ Plugin system
---
## ๐ Support
- [GitHub Issues](https://github.com/vbrazo/electron-audio-shot/issues)
- [Wiki](https://github.com/vbrazo/electron-audio-shot/wiki)
---
## ๐ฆ npm Package
```json
{
"name": "electron-audio-shot",
"version": "1.0.0",
"description": "Cross-platform audio + screenshot for Electron",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"peerDependencies": {
"electron": ">=20.0.0"
}
}
```
---
## ๐ Summary
- โ
Generic, production-ready
- โ
Cross-platform
- โ
Easy to integrate
- โ
React-compatible
- โ
Well-tested and documented
- โ
Community-ready