added example usage

This commit is contained in:
surajshivakumar
2024-06-12 06:54:42 -04:00
parent ed0223b9eb
commit 8c1e57be17

23
example/example.js Normal file
View File

@@ -0,0 +1,23 @@
const { AudioProcessor } = require('../index'); // Assuming your index.js is in the parent directory
async function runExample() {
const audioFilePath = '../audio/a.mp3';
const outputFilePath = './redacted_audio.wav';
try {
// Create a transcriber and a redactor from the factory
const transcriber = AudioProcessor.getTranscriber('deepgram',process.env.DEEPGRAM_API_KEY, audioFilePath);
const redactor = AudioProcessor.getRedactor('deepgram', audioFilePath);
// Perform transcription
const transcription = await transcriber.processAudio(audioFilePath);
console.log('Transcription completed:', transcription);
// Perform redaction
await redactor.redactAudio(transcription.redactionTimestamps, audioFilePath, outputFilePath);
} catch (error) {
console.error('Error processing audio:', error);
}
}
runExample();