forked from Blendman974/faceclaw
Move recording setting from Developer menu to Transcribe app; add prominent indicator
This commit is contained in:
1 parent
e158452ba4
commit
30de2c4dd7
24 files changed
+482
-153
No files matched your search
@@ -62,6 +62,9 @@ export class IosVoiceControlBridge {
|
||||
// and it is created by the first audio, so a failed start leaves no file.
|
||||
private recordingName = ''
|
||||
private recorder: WavRecorder | null = null
|
||||
// The file could not be created: one attempt per recording, not one per packet.
|
||||
private recordingFailure = false
|
||||
private readonly recordingListeners = new Set<() => void>()
|
||||
// Raw-PCM tap (EvenHub mic apps): decode-only glasses audio, broadcast to
|
||||
// rawListeners while any owner wants it, from the session setRawSession
|
||||
// bound. It shares the one glasses mic with speech capture, which preempts
|
||||
@@ -212,16 +215,28 @@ export class IosVoiceControlBridge {
|
||||
recordTo(name: string): void {
|
||||
if (name === this.recordingName) return
|
||||
this.recorder?.close(); this.recorder = null
|
||||
this.recordingName = name
|
||||
this.setRecording(name, false)
|
||||
}
|
||||
/** Whether continuous captures' audio is being saved (see recordTo). */
|
||||
get recording(): boolean { return this.recordingName !== '' && !this.recordingFailure }
|
||||
/** Whether the recording asked for could not be saved (its file could not be created). */
|
||||
get recordingFailed(): boolean { return this.recordingFailure }
|
||||
/** `recording` or `recordingFailed` changed. */
|
||||
onRecordingChange(listener: () => void): () => void { this.recordingListeners.add(listener); return () => { this.recordingListeners.delete(listener) } }
|
||||
private setRecording(name: string, failed: boolean): void {
|
||||
const wasRecording = this.recording, hadFailed = this.recordingFailure
|
||||
this.recordingName = name; this.recordingFailure = failed
|
||||
if (wasRecording === this.recording && hadFailed === failed) return
|
||||
for (const fn of [...this.recordingListeners]) fn()
|
||||
}
|
||||
private record(pcm: Uint8Array): void {
|
||||
if (!this.recorder && this.recordingName) {
|
||||
if (!this.recording) return
|
||||
if (!this.recorder) {
|
||||
this.recorder = WavRecorder.open(this.recordingName)
|
||||
this.log(this.recorder ? `Voice: recording audio to ${this.recorder.path}` : 'Voice: could not create the audio recording')
|
||||
// One attempt per recording, not one per packet.
|
||||
if (!this.recorder) this.recordingName = ''
|
||||
if (!this.recorder) { this.setRecording(this.recordingName, true); return }
|
||||
}
|
||||
this.recorder?.append(pcm)
|
||||
this.recorder.append(pcm)
|
||||
}
|
||||
/** End continuous capture, transcribing the audio since the last pause. */
|
||||
stopContinuousCapture(): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user