From 65162195ec16403e61ff83317f715591876b1f27 Mon Sep 17 00:00:00 2001 From: fegloff Date: Thu, 25 Jan 2024 12:50:22 -0500 Subject: [PATCH] add whisper payment for voice-command --- src/modules/voice-command/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/voice-command/index.ts b/src/modules/voice-command/index.ts index 3f8d3f90..e1e41d11 100644 --- a/src/modules/voice-command/index.ts +++ b/src/modules/voice-command/index.ts @@ -35,7 +35,9 @@ export class VoiceCommand implements PayableBot { } public getEstimatedPrice (ctx: OnMessageContext): number { - return 0 + const { voice } = ctx.update.message + const seconds = voice?.duration ?? 0 + return seconds * 0.005 } getCommand (transcribedText: string): string { @@ -82,7 +84,7 @@ export class VoiceCommand implements PayableBot { fs.renameSync(path, filename) const resultText = await speechToText(fs.createReadStream(filename)) - console.log('VoiceCommand prompt detected', resultText) + this.logger.info(`[VoiceCommand] prompt detected: ${resultText}`) fs.rmSync(filename) const command = this.getCommand(resultText)