forked from Blendman974/faceclaw
Merge branch 'main' of https://github.com/jimrandomh/faceclaw
This commit is contained in:
commit
c162c8e633
24 files changed
+486
-154
No files matched your search
@@ -1,4 +1,7 @@
|
||||
import { imageFromAsciiArt } from "../../graphics/image";
|
||||
import { imageFromAsciiArt, type GrayImage } from "../../graphics/image";
|
||||
import { voiceControlBridge } from "../../native/voice-control";
|
||||
import { saveRecordingSetting, toggleSettingMenuItem } from "../../ui/dashboard-settings";
|
||||
import { withRecordingIcon } from "../../ui/listening-header";
|
||||
import { TranscribeLayer, transcriptTimestamp } from "./transcribe";
|
||||
import {
|
||||
createInProcessWindow,
|
||||
@@ -13,8 +16,8 @@ export const TRANSCRIBE_SURFACE_ID = "window:transcribe";
|
||||
|
||||
const TRAY_ICON_ID = "transcribe";
|
||||
|
||||
// 16x18 microphone glyph for the top-bar tray (also Translate's).
|
||||
export const MIC_ICON = imageFromAsciiArt(
|
||||
// 14x15 microphone glyph for the top-bar tray (also Translate's).
|
||||
const MIC_ICON = imageFromAsciiArt(
|
||||
[
|
||||
" #### ",
|
||||
" ###### ",
|
||||
@@ -34,6 +37,12 @@ export const MIC_ICON = imageFromAsciiArt(
|
||||
],
|
||||
{ "#": 220 },
|
||||
);
|
||||
const MIC_RECORDING_ICON = withRecordingIcon(MIC_ICON);
|
||||
|
||||
/** The listening apps' tray icon: a microphone, with the recording circle while their audio is saved. */
|
||||
export function micTrayIcon(recording: boolean): GrayImage {
|
||||
return recording ? MIC_RECORDING_ICON : MIC_ICON;
|
||||
}
|
||||
|
||||
export type TranscribeAppOptions = InProcessAppOptions & {
|
||||
/** Begin continuous mic capture (kept on while the window is open). */
|
||||
@@ -59,18 +68,23 @@ export function createTranscribeAppWindow(options: TranscribeAppOptions): InProc
|
||||
closeable: true,
|
||||
actions: options.actions,
|
||||
baseLayer: new YieldAtRootLayer(layer),
|
||||
menuItems: () => [{
|
||||
label: "Save",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
layer.saveTranscript();
|
||||
menuItems: () => [
|
||||
{
|
||||
label: "Save",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
layer.saveTranscript();
|
||||
},
|
||||
},
|
||||
}],
|
||||
// The controller starts and stops the recording as the setting changes.
|
||||
toggleSettingMenuItem(saveRecordingSetting),
|
||||
],
|
||||
submitFrame: options.submitFrame,
|
||||
setSurfaceVisible: options.setSurfaceVisible,
|
||||
removeSurface: options.removeSurface,
|
||||
onClosed: () => {
|
||||
layer.onRemoved();
|
||||
unsubscribeRecording();
|
||||
options.stopContinuousVoiceCapture();
|
||||
shell.setTrayIcon(TRAY_ICON_ID, null);
|
||||
options.onClosed();
|
||||
@@ -79,7 +93,11 @@ export function createTranscribeAppWindow(options: TranscribeAppOptions): InProc
|
||||
// Wire async state changes to this window's renderer, rather than the
|
||||
// controller action from which the window-specific actions were derived.
|
||||
layer.start(app.requestRender, () => shell.isWindowVisible(TRANSCRIBE_WINDOW_ID));
|
||||
const unsubscribeRecording = voiceControlBridge.onRecordingChange(() => {
|
||||
shell.setTrayIcon(TRAY_ICON_ID, micTrayIcon(voiceControlBridge.recording));
|
||||
app.requestRender();
|
||||
});
|
||||
options.startContinuousVoiceCapture({ recordAs: `transcribe-${stamp}` });
|
||||
shell.setTrayIcon(TRAY_ICON_ID, MIC_ICON);
|
||||
shell.setTrayIcon(TRAY_ICON_ID, micTrayIcon(voiceControlBridge.recording));
|
||||
return app;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { GrayImage } from "../../graphics/image";
|
||||
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
|
||||
import { lineStep } from "../../ui/metrics";
|
||||
import { MicLevelMeter, paintListeningHeader } from "../../ui/listening-header";
|
||||
import { MicLevelMeter, paintListeningHeader, RECORDING_FAILED_NOTICE } from "../../ui/listening-header";
|
||||
import { writeTextToDownloads } from "../../native/file-access";
|
||||
import { voiceControlBridge } from "../../native/voice-control";
|
||||
import { Layer, type LayerContext } from "../../ui/layers";
|
||||
@@ -50,8 +50,11 @@ export class TranscribeLayer implements Layer {
|
||||
const viewport = ctx.stack.getBaseSize();
|
||||
const image = new GrayImage(viewport.width, viewport.height, 0);
|
||||
|
||||
const bodyTop = paintListeningHeader(image, font, "Transcribe", this.saveNotice || this.status, this.listening ? this.meter : null,
|
||||
viewport.padding);
|
||||
const status = voiceControlBridge.recordingFailed ? RECORDING_FAILED_NOTICE : this.status;
|
||||
const bodyTop = paintListeningHeader(
|
||||
image, font, "Transcribe", this.saveNotice || status, this.listening ? this.meter : null, viewport.padding,
|
||||
voiceControlBridge.recording,
|
||||
);
|
||||
const step = lineStep(font) + 2;
|
||||
const layout = transcriptLayout(viewport, bodyTop, font.lineHeight, step);
|
||||
const text = this.transcript.text || (this.listening ? "Listening..." : this.detail);
|
||||
|
||||
Reference in new issue
Block a user