diff --git a/src/job-types/blockChain-block-number.ts b/src/job-types/blockChain-block-number.ts index 555d3ee..a344803 100644 --- a/src/job-types/blockChain-block-number.ts +++ b/src/job-types/blockChain-block-number.ts @@ -18,7 +18,8 @@ export async function blockChainBlockNumberJob( return closestObject.block_index.toString() }) .catch((err) => { - console.log('err in blockChain request :>> ', err) + log('err in blockChain request :>> ', err) + return Promise.reject(err) }) diff --git a/src/job-types/speech-to-text.ts b/src/job-types/speech-to-text.ts index 7c353b3..baa6873 100644 --- a/src/job-types/speech-to-text.ts +++ b/src/job-types/speech-to-text.ts @@ -1,9 +1,8 @@ import { NDKEvent, type NostrEvent } from '@nostr-dev-kit/ndk' import axios from 'axios' import FormData from 'form-data' -import { log } from '../main.js' import { fetchFileFromInput } from '../utils/fetch-file-from-input.js' -import { ndk } from '../main.js' +import { ndk, log } from '../main.js' // import { fileTypeFromFile, type FileTypeResult } from 'file-type'; import { exec } from 'child_process' import fs from 'fs' @@ -43,7 +42,8 @@ export async function speechToTextJob(event: NDKEvent): Promise { } const formData = new FormData() const a = fs.createReadStream(file) - console.log({ a }) + + log({ a }) formData.append('file', a) formData.append('model', 'whisper-1') @@ -57,12 +57,14 @@ export async function speechToTextJob(event: NDKEvent): Promise { }) .then((response) => { const { text } = response.data - console.log({ text }) + + log({ text }) + resolve(text) // Handle response }) .catch((error) => { - console.log({ error }) + log({ error }) // Handle error }) }, 1000) @@ -78,9 +80,11 @@ export async function speechToTextJob(event: NDKEvent): Promise { const endTime = range[3] const randomName = Math.random().toString(36).substring(7) + '.mp3' const command = `ffmpeg -ss ${startTime} -to ${endTime} -i ${file} -vn -acodec copy ${randomName}` - console.log({ startTime, endTime, randomName, command }) + + log({ startTime, endTime, randomName, command }) + exec(command, (error, stderr, stdout) => { - console.log('ffmpeg', { error, stderr, stdout }) + log('ffmpeg', { error, stderr, stdout }) whisperCommand(resolve, randomName) }) diff --git a/src/job-types/summarization.ts b/src/job-types/summarization.ts index 5426f8c..89f649a 100644 --- a/src/job-types/summarization.ts +++ b/src/job-types/summarization.ts @@ -4,7 +4,7 @@ import { inProgress } from '../jobs/reactions/in-progress.js' import { log } from '../main.js' export async function onNewSummarizationJob(event: NDKEvent): Promise { - console.log('New summarization job') + log('New summarization job') await validateJobRequest(event).catch((err) => log(`Job validation error: `, err) diff --git a/src/jobs/reactions/status.ts b/src/jobs/reactions/status.ts index 340bbd7..4dfc0c6 100644 --- a/src/jobs/reactions/status.ts +++ b/src/jobs/reactions/status.ts @@ -14,7 +14,7 @@ export async function publishStatus( tags: [['status', status], ...extraTags] }) - console.log({ extraTags }) + log({ extraTags }) reactEvent.tag(event, 'job') await reactEvent.sign() diff --git a/src/main.ts b/src/main.ts index de1bcc6..f1c8fe2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -257,9 +257,7 @@ async function processJobEvent(event: NDKEvent, type: JobType): Promise { await startProcessing() - await publishStatus(event, 'finished').catch((err) => - console.log('err :>> ', err) - ) + await publishStatus(event, 'finished').catch((err) => log('err :>> ', err)) if (jobAmount > paidAmount && waitForPaymentBeforePublishingResult()) { await reqPayment() diff --git a/src/validations/index.ts b/src/validations/index.ts index 2752dba..7a956dd 100644 --- a/src/validations/index.ts +++ b/src/validations/index.ts @@ -2,7 +2,7 @@ import { NDKEvent, type NostrEvent } from '@nostr-dev-kit/ndk' import validateExpiration from './expiration.js' import validateRequester from './requester.js' import validateNoRecentResults from './no-recent-results.js' -import { ndk } from '../main.js' +import { ndk, log } from '../main.js' import { addAmount } from '../job-types/speech-to-text.js' export async function validateJobRequest(event: NDKEvent): Promise { @@ -40,7 +40,8 @@ export async function requirePayment( payReq.tag(event, 'job') await payReq.sign() - console.log(payReq.rawEvent()) + + log(payReq.rawEvent()) if (publish !== false) await payReq.publish()