From a9adef1fb9026fdff16f440d381af362ce445bed Mon Sep 17 00:00:00 2001 From: choomba Date: Sat, 15 Jul 2023 11:16:33 -0700 Subject: [PATCH 1/2] Graph: Connect audioBytes and responseInput events Associating responseInput events with the audioBytes event that triggered it will help differentiate between keyboard input and VAD. It also results in a cleaner graph. --- index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index 8cf7db5..bdf49ee 100644 --- a/index.ts +++ b/index.ts @@ -132,7 +132,7 @@ const getCutTimestamp = (): number => { return Math.max(lastResponseReflex, lastCut); } -const getTransciptionSoFar = (): string => { +const getTranscriptionSoFar = (): string => { const lastResponseReflex = getLastResponseReflexTimestamp(); const cutTranscriptionEvents = eventlog.events.filter(e => e.eventType === 'cutTranscription' && e.timestamp > lastResponseReflex); const lastTranscriptionEvent = getLastTranscriptionEvent(); @@ -262,7 +262,7 @@ const transcriptionEventHandler = async (event: AudioBytesEvent) => { const lastTranscription = getLastTranscriptionEvent() const doneSpeaking = whisper.finishedVoiceActivity(activityBuffer, VAD_SAMPLE_MS, VAD_THOLD, VAD_ENERGY_THOLD); if (doneSpeaking && lastTranscription && lastTranscription.data.transcription.length) { - return responseInputEventHandler(); + return responseInputEventHandler(event); } } const joinedBuffer = Buffer.concat( @@ -326,7 +326,7 @@ const responseReflexEventHandler = async (event: TranscriptionEvent): Promise (e.eventType === 'responseInput')); const lastResponseInputTimestamp = responseInputEvents.length > 0 ? responseInputEvents[responseInputEvents.length - 1].timestamp : eventlog.events[0].timestamp; if (lastResponseInputTimestamp > lastTranscriptionEventTimestamp) { - const transcription = getTransciptionSoFar(); + const transcription = getTranscriptionSoFar(); if (transcription) { const responseReflexEvent: ResponseReflexEvent = { timestamp: Number(Date.now()), @@ -400,13 +400,13 @@ const talkEventHandler = async (event: ResponseReflexEvent): Promise => { } } -const responseInputEventHandler = (): void => { +const responseInputEventHandler = (event: void | AudioBytesEvent): void => { const responseInputEvent: ResponseInputEvent = { eventType: 'responseInput', timestamp: Number(Date.now()), data: {} } - newEventHandler(responseInputEvent); + newEventHandler(responseInputEvent, event); } // Defines the DAG through which events trigger each other From e178f8bfbfc2ad6283925154223aa79004c71fe8 Mon Sep 17 00:00:00 2001 From: choomba Date: Sat, 15 Jul 2023 11:19:50 -0700 Subject: [PATCH 2/2] Bump piper to v1.1 --- install_piper.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install_piper.sh b/install_piper.sh index e0a06fc..b887f76 100755 --- a/install_piper.sh +++ b/install_piper.sh @@ -22,11 +22,11 @@ function main() { # Set download link based on architecture if [ "$ARCH" = "x86_64" ]; then - DOWNLOAD_LINK="https://github.com/rhasspy/piper/releases/download/v1.0.0/piper_amd64.tar.gz" + DOWNLOAD_LINK="https://github.com/rhasspy/piper/releases/download/v1.1.0/piper_amd64.tar.gz" elif [ "$ARCH" = "aarch64" ]; then - DOWNLOAD_LINK="https://github.com/rhasspy/piper/releases/download/v1.0.0/piper_arm64.tar.gz" + DOWNLOAD_LINK="https://github.com/rhasspy/piper/releases/download/v1.1.0/piper_arm64.tar.gz" elif [ "$ARCH" = "armv7l" ]; then - DOWNLOAD_LINK="https://github.com/rhasspy/piper/releases/download/v1.0.0/piper_armv7.tar.gz" + DOWNLOAD_LINK="https://github.com/rhasspy/piper/releases/download/v1.1.0/piper_armv7.tar.gz" else echo "Unsupported architecture: $ARCH. You will have to manually compile and install piper from their repo https://github.com/rhasspy/piper/" return