Skip to content

Commit 5264450

Browse files
authored
Fix fetch transcript (#2086)
* fix audio path import
1 parent 9cc5ee9 commit 5264450

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/server/transcripts/flagger.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import { createWriteStream, existsSync } from 'fs';
22
import { readFile } from 'fs/promises';
33
import { Readable } from 'stream';
44
import { finished } from 'stream/promises';
5-
import path from 'path';
65
import { FFmpeg } from '@ffmpeg.wasm/main';
76
import type { Show } from '@prisma/client';
87
import core from '@ffmpeg.wasm/core-mt';
8+
import { VERCEL } from '$env/static/private';
99
import { logProgress } from './logProgress';
1010

11-
const flag_paths = ['./audio/wes-flagger.mp3', './audio/scott-flagger.mp3'];
11+
import wes_flagger from './audio/wes-flagger.mp3';
12+
import scott_flagger from './audio/scott-flagger.mp3';
13+
14+
const flag_paths = [wes_flagger, scott_flagger].map((path) =>
15+
VERCEL ? `.vercel/output/static${path}` : path
16+
);
1217

1318
export type ProgressEvent = {
1419
duration?: number;
@@ -79,9 +84,7 @@ export async function addFlaggerAudio(show: Show): Promise<Buffer> {
7984
console.log(`wrote ${file_name} to ffmpeg memory`);
8085
// Write Flaggers to ffmpeg memory
8186
for (const [i, flag_path] of flag_paths.entries()) {
82-
// eslint-disable-next-line @typescript-eslint/naming-convention
83-
const __dirname = new URL('.', import.meta.url).pathname;
84-
const flag_buffer = await readFile(path.join(__dirname, flag_path));
87+
const flag_buffer = await readFile(flag_path);
8588
ffmpeg.fs.writeFile(`flagger-${base_name}-${i}.mp3`, flag_buffer);
8689
console.log(`wrote flagger-${base_name}-${i}.mp3 to ffmpeg memory`);
8790
}

0 commit comments

Comments
 (0)