-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28b785e
commit c80db41
Showing
8 changed files
with
666 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as stream from 'stream'; | ||
import archiver from 'archiver'; | ||
import { Transcripts } from '../../worker/src/transcribe'; | ||
import { promisify } from 'util'; | ||
|
||
export const getZipBlob = async (files: Transcripts) => { | ||
// Create an archive stream and buffer | ||
const archive = archiver('zip', { zlib: { level: 9 } }); | ||
const bufferStream = new stream.PassThrough(); | ||
const chunks: Uint8Array[] = []; | ||
|
||
// Listen for 'data' events to collect chunks of the zip file | ||
bufferStream.on('data', (chunk) => chunks.push(chunk)); | ||
|
||
// Pipe the archive data to the buffer stream | ||
archive.pipe(bufferStream); | ||
|
||
// Add files to the archive | ||
archive.append(files.srt, { name: 'transcript.srt' }); | ||
archive.append(files.text, { name: 'transcript.txt' }); | ||
archive.append(files.json, { name: 'transcript.json' }); | ||
|
||
// Finalize the archive (ensures all files are added) | ||
archive.finalize(); | ||
|
||
// Wait for the archive to complete and concatenate chunks into a Blob | ||
await promisify(stream.finished)(bufferStream); // Ensure the stream finishes | ||
const zipBlob = new Blob(chunks, { type: 'application/zip' }); | ||
|
||
return zipBlob; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters