feat: 添加音频录制模块及示例,支持纯JavaScript环境

This commit is contained in:
2025-12-24 00:33:03 +08:00
parent b6157deec9
commit dd7e44a4b8
8 changed files with 784 additions and 4 deletions

View File

@@ -50,10 +50,10 @@ export class Relatime {
const voice = data.toString('base64');
this.asr.ws.send(JSON.stringify({ voice }));
}
sendBase64(data: string) {
sendBase64(data: string, opts?: { isRelatime?: boolean }) {
if (!this.ready) return;
console.log('send 花费时间:', Date.now() - this.startTime);
this.asr.ws.send(JSON.stringify({ voice: data, format: 'float32', time: Date.now() }));
this.asr.ws.send(JSON.stringify({ voice: data, format: 'float32', time: Date.now(), ...opts }));
// if (this.timeoutHandle) {
// clearTimeout(this.timeoutHandle);
// }