The error audioService.off is not a function was occurring because:
- Wrong EventEmitter: The
SystemAudioCaptureServicewas trying to use Node.jsEventEmitterin a browser environment - Missing Methods: The browser doesn't have access to Node.js
EventEmitterclass - Import Issues: Browser-incompatible imports were causing runtime errors
- Replaced Node.js
EventEmitterwith customAudioEventEmitter - Added proper
.on(),.off(),.emit(), and.removeAllListeners()methods - Ensured browser compatibility with proper TypeScript types
- Included error handling in event listeners
SystemAudioCaptureServicenow extendsAudioEventEmitter- All methods (.on, .off, .emit) are now available and functional
- TypeScript compatible with proper type definitions
- Browser-safe implementation without Node.js dependencies
After refreshing the assistant window, you should now be able to:
- Switch to System Audio mode without errors
- Use all audio source types:
- 🎤 Microphone only
- 🔊 System audio only (YouTube, Zoom, etc.)
- 🎧 Mixed mode (both simultaneously)
- Grant permissions when prompted
- See real-time transcription from system audio
- Refresh the assistant window (Cmd+R or Ctrl+R)
- Navigate to the Transcripts page
- Click "🎧 System Audio" mode in the top-right toggle
- No more
audioService.off is not a functionerrors - Test with YouTube video or system audio
- ✅
src/services/system-audio-capture.ts- Fixed EventEmitter implementation - ✅
src/hooks/useSystemAudioTranscription.tsx- Uses fixed service - ✅
src/components/SystemAudioTranscriptionComponent.tsx- UI component - ✅
src/pages/assistant/TranscriptsPage.tsx- Mode switching
The fix involved replacing this:
// ❌ Node.js EventEmitter (doesn't work in browser)
import { EventEmitter } from 'events'
export class SystemAudioCaptureService extends EventEmitterWith this:
// ✅ Browser-compatible custom EventEmitter
export class AudioEventEmitter {
on(event, listener) { /* browser-safe implementation */ }
off(event, listener) { /* browser-safe implementation */ }
emit(event, ...args) { /* browser-safe implementation */ }
}
export class SystemAudioCaptureService extends AudioEventEmitterThe system audio transcription should now work without the audioService.off is not a function error. Try refreshing and switching to System Audio mode!