mirror of
https://github.com/jambonz/batch-speech-utils.git
synced 2025-12-19 06:07:43 +00:00
added example usage
This commit is contained in:
23
example/example.js
Normal file
23
example/example.js
Normal 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();
|
||||
Reference in New Issue
Block a user