example added

This commit is contained in:
surajshivakumar
2024-06-14 03:23:06 -04:00
parent e279a60480
commit e00454e6e6

View File

@@ -1,21 +1,26 @@
const { getTranscription, getRedactedAudio } = require('..'); // Assuming your index.js is in the parent directory
// app.js
const createAudioService = require('..');
const audioService = createAudioService();
// Get the transcription service configured with the default noopLogger
// Example usage of the transcribe function
async function runExample() {
const audioFilePath = '../audio/a.mp3';
const outputFilePath = './outs/redacted_audio.wav';
const credentials = {'vendor': 'deepgram', 'apiKey': process.env.DEEPGRAM_API_KEY};
try {
// Create a transcriber and a redactor from the factory
const transcription = await getTranscription('deepgram',
process.env.DEEPGRAM_API_KEY,
audioFilePath);
console.log('Transcription completed:', transcription);
// Perform redaction
await getRedactedAudio('deepgram', transcription.redactionTimestamps, audioFilePath, outputFilePath);
const transcriptionResults = await audioService.transcribe(credentials, audioFilePath);
// console.log('Transcription Results:', transcriptionResults);
const timestampsToRedact = transcriptionResults.redactionTimestamps;
// eslint-disable-next-line max-len
await audioService.redact({credentials:credentials, transcriptionData:timestampsToRedact, audioPath:audioFilePath, audioOutputPath:outputFilePath });
} catch (error) {
console.error('Error processing audio:', error);
console.error('Failed to redact audio:', error);
}
}
runExample();