Skip to content

feat(formatResponse): return the response in the corresponding format - #170

Open
MrSwitch wants to merge 1 commit into
ChetanXpro:mainfrom
MrSwitch:responseFormat
Open

feat(formatResponse): return the response in the corresponding format#170
MrSwitch wants to merge 1 commit into
ChetanXpro:mainfrom
MrSwitch:responseFormat

Conversation

@MrSwitch

@MrSwitch MrSwitch commented Feb 18, 2025

Copy link
Copy Markdown
Contributor

Fixes #120

Returns the output formats in a desired format. This is particularly useful to capture a json response.

aka, now..

   const transcription = await nodewhisper(audioPath, {
        modelName: 'base.en',
        responseFormat: 'json'
    }); // returns JSON object

previously....

import fs from 'fs';
import path from 'path';
...
await nodewhisper(audioPath, {
        modelName: 'base.en',
        whisperOptions: {
            outputInJson: true
        }
 });
const response = fs.readFileSync(`${path.join(path.dirname(audioPath), path.basename(audioPath, path.extname(audioPath)))}.wav.json`, 'utf8');
const transcription = JSON.parse(response);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't get JSON file

1 participant