This commit significantly expands the application's routing, navigation, and administrative capabilities. It introduces several new functional modules and refines the core layout for a more professional, dashboard-oriented experience. - **Routing & Navigation**: - Added routes for `wallboard`, `call-center`, `call-center/calls`, and `chat-questions`. - Updated `SidebarComponent` to include all new navigation items. - Enhanced `LayoutComponent` with dynamic navigation based on user roles (admin vs. user). - **New Administrative Pages**: - `WallboardPage`: Implements a real-time KPI dashboard with call activity trends and outcome distributions. - `CallCenterPage`: Provides a symbolic interface for managing call center connectivity and synchronization. - `CallCenterCallsPage`: Implements a call history retrieval interface with filtering capabilities. - `ChatQuestionsPage`: Adds a module for reviewing user questions from web and mobile channels. - **Core Infrastructure & Refinement**: - Updated `AppConfig` to include an `APP_INITIALIZER` for validating user identity via `AuthService` on startup. - Refined `HomeComponent` layout to a "Claude-style" continuous chat column. - Implemented global themed scrollbars and integrated the 'Lahze' font family. - Added `proxy.conf.json` and updated `angular.json` to support local backend development. - **Documentation**: - Added comprehensive API handoff guides for frontend-backend connection and MVP API catalog.
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
/**
|
|
* Mic capture: downsamples the context rate to `targetRate` (default 24 kHz per the
|
|
* voice contract), converts to PCM16 mono and posts fixed-size frames (default 20 ms)
|
|
* to the main thread. Frames are always sample-aligned PCM16.
|
|
* Message: { pcm: ArrayBuffer (Int16), rms: number (0..1) }
|
|
*/
|
|
class PcmCaptureProcessor extends AudioWorkletProcessor {
|
|
constructor(options) {
|
|
super();
|
|
const o = (options && options.processorOptions) || {};
|
|
this.targetRate = o.targetRate || 24000;
|
|
this.frameSamples = o.frameSamples || 480;
|
|
this.ratio = sampleRate / this.targetRate; // input samples per output sample
|
|
this.pos = 0;
|
|
this.sum = 0;
|
|
this.count = 0;
|
|
this.frame = new Float32Array(this.frameSamples);
|
|
this.filled = 0;
|
|
}
|
|
|
|
process(inputs) {
|
|
const channel = inputs[0] && inputs[0][0];
|
|
if (!channel) return true;
|
|
|
|
for (let i = 0; i < channel.length; i++) {
|
|
this.sum += channel[i];
|
|
this.count++;
|
|
this.pos += 1;
|
|
if (this.pos >= this.ratio) {
|
|
// box-filter average of the input samples that fall into one output sample
|
|
this.frame[this.filled++] = this.sum / this.count;
|
|
this.sum = 0;
|
|
this.count = 0;
|
|
this.pos -= this.ratio;
|
|
if (this.filled === this.frameSamples) this.flush();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
flush() {
|
|
const out = new Int16Array(this.frameSamples);
|
|
let energy = 0;
|
|
for (let i = 0; i < this.frameSamples; i++) {
|
|
const v = Math.max(-1, Math.min(1, this.frame[i]));
|
|
energy += v * v;
|
|
out[i] = v < 0 ? v * 0x8000 : v * 0x7fff;
|
|
}
|
|
this.filled = 0;
|
|
this.port.postMessage({ pcm: out.buffer, rms: Math.sqrt(energy / this.frameSamples) }, [out.buffer]);
|
|
}
|
|
}
|
|
|
|
registerProcessor('pcm-capture', PcmCaptureProcessor); |