From adabd05635229685b05b0a9b26a5581aa71933ae Mon Sep 17 00:00:00 2001 From: sobird Date: Thu, 20 Feb 2025 01:56:07 +0800 Subject: [PATCH] fix: spwan sox on data event only run 108 seconds --- .github/workflows/ci.yml | 4 ++-- index.ts | 4 ---- services/AudioService.ts | 10 +++++++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edd9e42..be302dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,8 +3,8 @@ name: Continuous Integration on: push: branches: [ "master" ] - # pull_request: - # branches: [ "master" ] + pull_request: + branches: [ "master" ] workflow_dispatch: jobs: diff --git a/index.ts b/index.ts index 82004d3..c0c5737 100755 --- a/index.ts +++ b/index.ts @@ -46,7 +46,6 @@ const command = program const spinner = ora({ discardStdin: false, - // text: 'Loading...', spinner: { frames: [ randomWave(), @@ -62,12 +61,9 @@ const command = program keypress((str, key) => { if (key.name === 'space') { space = !space; - if (space) { mqttService.startListening(); spinner.start(); - - // keypress } else { spinner.stop(); mqttService.stopListening(); diff --git a/services/AudioService.ts b/services/AudioService.ts index e072058..a71e47e 100644 --- a/services/AudioService.ts +++ b/services/AudioService.ts @@ -108,6 +108,10 @@ export class AudioService { }); }); + sox.stderr.on('data', () => { + // console.error(data.toString()); + }); + mic.on('error', (err) => { console.error(`send audio error: ${err}`); }); @@ -137,9 +141,9 @@ export class AudioService { '-t', process.platform === 'win32' ? 'waveaudio' : 'coreaudio', '-d', // 输出到默认音频设备 ]); - // sox.stderr.on('data', (data) => { - // console.error(data.toString()); - // }); + sox.stderr.on('data', () => { + // console.error(data.toString()); + }); const opusScript = new OpusScript(outputSampleRate, outputChannels, OpusScript.Application.AUDIO);