"feat: 更新ASR服务连接配置,优化录音流处理及模型路径"

This commit is contained in:
2025-06-02 12:38:53 +08:00
parent e638d7907a
commit 232d799575
8 changed files with 242 additions and 26 deletions

View File

@@ -3,7 +3,6 @@ import { logger } from '../logger/index.ts';
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
import recorders from '../recorder/recorders/index.ts';
import Stream from 'stream';
const logDebug = logger.debug;
export type RecordingOptions = {
/* 采样率默认为16000 */
sampleRate?: number;
@@ -64,9 +63,9 @@ export class Recording {
this.args = args;
this.cmdOptions = Object.assign({ encoding: 'binary', stdio: 'pipe' }, spawnOptions);
logDebug(`Started recording`);
logDebug('options', this.options);
logDebug(` ${this.cmd} ${this.args.join(' ')}`);
logger.debug(`Started recording`);
logger.debug('options', this.options);
logger.debug(` ${this.cmd} ${this.args.join(' ')}`);
return this.start();
}
@@ -92,15 +91,15 @@ Enable debugging with the environment variable DEBUG=record.`,
});
err.on('data', (chunk) => {
logDebug(`STDERR: ${chunk}`);
logger.debug(`STDERR: ${chunk}`);
});
rec.on('data', (chunk) => {
logDebug(`Recording ${chunk.length} bytes`);
logger.debug(`Recording ${chunk.length} bytes`);
});
rec.on('end', () => {
logDebug('Recording ended');
logger.debug('Recording ended');
});
return this;
@@ -117,7 +116,7 @@ Enable debugging with the environment variable DEBUG=record.`,
this.process.kill('SIGSTOP');
this._stream.pause();
logDebug('Paused recording');
logger.debug('Paused recording');
}
resume() {
@@ -125,7 +124,7 @@ Enable debugging with the environment variable DEBUG=record.`,
this.process.kill('SIGCONT');
this._stream.resume();
logDebug('Resumed recording');
logger.debug('Resumed recording');
}
isPaused() {