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