eprec 0.0.1 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -29
  3. package/cli.ts +150 -0
  4. package/package.json +39 -7
  5. package/process-course/chapter-processor.ts +1037 -0
  6. package/process-course/cli.ts +236 -0
  7. package/process-course/config.ts +50 -0
  8. package/process-course/edits/cli.ts +167 -0
  9. package/process-course/edits/combined-video-editor.ts +316 -0
  10. package/process-course/edits/edit-workspace.ts +90 -0
  11. package/process-course/edits/index.ts +20 -0
  12. package/process-course/edits/regenerate-transcript.ts +84 -0
  13. package/process-course/edits/remove-ranges.test.ts +36 -0
  14. package/process-course/edits/remove-ranges.ts +287 -0
  15. package/process-course/edits/timestamp-refinement.test.ts +25 -0
  16. package/process-course/edits/timestamp-refinement.ts +172 -0
  17. package/process-course/edits/transcript-diff.test.ts +105 -0
  18. package/process-course/edits/transcript-diff.ts +214 -0
  19. package/process-course/edits/transcript-output.test.ts +50 -0
  20. package/process-course/edits/transcript-output.ts +36 -0
  21. package/process-course/edits/types.ts +26 -0
  22. package/process-course/edits/video-editor.ts +246 -0
  23. package/process-course/errors.test.ts +63 -0
  24. package/process-course/errors.ts +82 -0
  25. package/process-course/ffmpeg.ts +449 -0
  26. package/process-course/jarvis-commands/handlers.ts +71 -0
  27. package/process-course/jarvis-commands/index.ts +14 -0
  28. package/process-course/jarvis-commands/parser.test.ts +348 -0
  29. package/process-course/jarvis-commands/parser.ts +257 -0
  30. package/process-course/jarvis-commands/types.ts +46 -0
  31. package/process-course/jarvis-commands/windows.ts +254 -0
  32. package/process-course/logging.ts +24 -0
  33. package/process-course/paths.test.ts +59 -0
  34. package/process-course/paths.ts +53 -0
  35. package/process-course/summary.test.ts +209 -0
  36. package/process-course/summary.ts +210 -0
  37. package/process-course/types.ts +85 -0
  38. package/process-course/utils/audio-analysis.test.ts +348 -0
  39. package/process-course/utils/audio-analysis.ts +463 -0
  40. package/process-course/utils/chapter-selection.test.ts +307 -0
  41. package/process-course/utils/chapter-selection.ts +136 -0
  42. package/process-course/utils/file-utils.test.ts +83 -0
  43. package/process-course/utils/file-utils.ts +57 -0
  44. package/process-course/utils/filename.test.ts +27 -0
  45. package/process-course/utils/filename.ts +12 -0
  46. package/process-course/utils/time-ranges.test.ts +221 -0
  47. package/process-course/utils/time-ranges.ts +86 -0
  48. package/process-course/utils/transcript.test.ts +257 -0
  49. package/process-course/utils/transcript.ts +86 -0
  50. package/process-course/utils/video-editing.ts +44 -0
  51. package/process-course-video.ts +389 -0
  52. package/speech-detection.ts +355 -0
  53. package/utils.ts +138 -0
  54. package/whispercpp-transcribe.ts +345 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kent C. Dodds
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,68 @@
1
- # eprec
1
+ <div align="center">
2
+ <h1>eprec</h1>
2
3
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
4
+ <p>Tools for processing Epic Web course recordings</p>
5
+ </div>
4
6
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
7
+ ---
6
8
 
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
9
+ <!-- prettier-ignore-start -->
10
+ [![Build Status][build-badge]][build]
11
+ [![version][version-badge]][package]
12
+ [![downloads][downloads-badge]][npmtrends]
13
+ [![MIT License][license-badge]][license]
14
+ <!-- prettier-ignore-end -->
8
15
 
9
- ## Purpose
16
+ ## Installation
10
17
 
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `eprec`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
18
+ To install dependencies:
15
19
 
16
- ## What is OIDC Trusted Publishing?
20
+ ```bash
21
+ bun install
22
+ ```
17
23
 
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
24
+ To run:
19
25
 
20
- ## Setup Instructions
26
+ ```bash
27
+ bun run index.ts
28
+ ```
21
29
 
22
- To properly configure OIDC trusted publishing for this package:
30
+ ## Whisper.cpp transcription (optional)
23
31
 
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
32
+ Install the local whisper.cpp CLI (Homebrew):
28
33
 
29
- ## DO NOT USE THIS PACKAGE
34
+ ```bash
35
+ brew install whisper-cpp
36
+ ```
30
37
 
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
38
+ The default small English model is downloaded on first use and cached at
39
+ `.cache/whispercpp/ggml-small.en.bin`. Replace that file (or pass
40
+ `--whisper-model-path`) to use a different model.
36
41
 
37
- ## More Information
42
+ Enable transcription with `--enable-transcription` when running
43
+ `process-course-video.ts` to skip chapters that include "jarvis bad take" or
44
+ "bad take jarvis". If the CLI isn't on your PATH, pass `--whisper-binary-path`
45
+ with the full path to `whisper-cli`.
38
46
 
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
47
+ Customize skip phrases by repeating `--whisper-skip-phrase` (do not use
48
+ comma-separated values because phrases may include commas).
42
49
 
43
- ---
50
+ Manual test checklist:
51
+
52
+ - Run with `--enable-transcription` and confirm whisper.cpp runs locally.
53
+ - Verify a chapter containing the phrase is skipped and logged.
54
+ - Verify a normal chapter still renders and writes output.
55
+
56
+ This project was created using `bun init` in bun v1.3.1. [Bun](https://bun.com)
57
+ is a fast all-in-one JavaScript runtime.
44
58
 
45
- **Maintained for OIDC setup purposes only**
59
+ <!-- prettier-ignore-start -->
60
+ [build-badge]: https://img.shields.io/github/actions/workflow/status/epicweb-dev/eprec/validate.yml?branch=main&logo=github&style=flat-square
61
+ [build]: https://github.com/epicweb-dev/eprec/actions?query=workflow%3Avalidate
62
+ [version-badge]: https://img.shields.io/npm/v/eprec.svg?style=flat-square
63
+ [package]: https://www.npmjs.com/package/eprec
64
+ [downloads-badge]: https://img.shields.io/npm/dm/eprec.svg?style=flat-square
65
+ [npmtrends]: https://www.npmtrends.com/eprec
66
+ [license-badge]: https://img.shields.io/npm/l/eprec.svg?style=flat-square
67
+ [license]: https://github.com/epicweb-dev/eprec/blob/main/LICENSE
68
+ <!-- prettier-ignore-end -->
package/cli.ts ADDED
@@ -0,0 +1,150 @@
1
+ #!/usr/bin/env bun
2
+ import path from 'node:path'
3
+ import type { CommandBuilder, CommandHandler } from 'yargs'
4
+ import yargs from 'yargs/yargs'
5
+ import { hideBin } from 'yargs/helpers'
6
+ import { ensureFfmpegAvailable } from './process-course/ffmpeg'
7
+ import {
8
+ normalizeProcessArgs,
9
+ configureProcessCommand,
10
+ } from './process-course/cli'
11
+ import { runProcessCourse } from './process-course-video'
12
+ import {
13
+ configureEditVideoCommand,
14
+ configureCombineVideosCommand,
15
+ handleCombineVideosCommand,
16
+ handleEditVideoCommand,
17
+ } from './process-course/edits/cli'
18
+ import { detectSpeechSegmentsForFile } from './speech-detection'
19
+ import {
20
+ getDefaultWhisperModelPath,
21
+ transcribeAudio,
22
+ } from './whispercpp-transcribe'
23
+
24
+ function resolveOptionalString(value: unknown) {
25
+ if (typeof value !== 'string') {
26
+ return undefined
27
+ }
28
+ const trimmed = value.trim()
29
+ return trimmed.length > 0 ? trimmed : undefined
30
+ }
31
+
32
+ async function main() {
33
+ const parser = yargs(hideBin(process.argv))
34
+ .scriptName('eprec')
35
+ .command(
36
+ 'process <input...>',
37
+ 'Process chapters into separate files',
38
+ configureProcessCommand,
39
+ async (argv) => {
40
+ const args = normalizeProcessArgs(argv)
41
+ await runProcessCourse(args)
42
+ },
43
+ )
44
+ .command(
45
+ 'edit',
46
+ 'Edit a single video using transcript text edits',
47
+ configureEditVideoCommand as CommandBuilder,
48
+ handleEditVideoCommand as CommandHandler,
49
+ )
50
+ .command(
51
+ 'combine',
52
+ 'Combine two videos with speech-aligned padding',
53
+ configureCombineVideosCommand as CommandBuilder,
54
+ handleCombineVideosCommand as CommandHandler,
55
+ )
56
+ .command(
57
+ 'transcribe <input>',
58
+ 'Transcribe a single audio/video file',
59
+ (command) =>
60
+ command
61
+ .positional('input', {
62
+ type: 'string',
63
+ describe: 'Input audio/video file',
64
+ })
65
+ .option('model-path', {
66
+ type: 'string',
67
+ describe: 'Path to whisper.cpp model file',
68
+ default: getDefaultWhisperModelPath(),
69
+ })
70
+ .option('language', {
71
+ type: 'string',
72
+ describe: 'Language passed to whisper.cpp',
73
+ default: 'en',
74
+ })
75
+ .option('threads', {
76
+ type: 'number',
77
+ describe: 'Thread count for whisper.cpp',
78
+ })
79
+ .option('binary-path', {
80
+ type: 'string',
81
+ describe: 'Path to whisper.cpp CLI (whisper-cli)',
82
+ })
83
+ .option('output-base', {
84
+ type: 'string',
85
+ describe: 'Output base path (without extension)',
86
+ }),
87
+ async (argv) => {
88
+ const inputPath = path.resolve(String(argv.input))
89
+ const outputBasePath =
90
+ resolveOptionalString(argv['output-base']) ??
91
+ path.join(
92
+ path.dirname(inputPath),
93
+ `${path.parse(inputPath).name}-transcript`,
94
+ )
95
+ const threads =
96
+ typeof argv.threads === 'number' && Number.isFinite(argv.threads)
97
+ ? argv.threads
98
+ : undefined
99
+ const result = await transcribeAudio(inputPath, {
100
+ modelPath: resolveOptionalString(argv['model-path']),
101
+ language: resolveOptionalString(argv.language),
102
+ threads,
103
+ binaryPath: resolveOptionalString(argv['binary-path']),
104
+ outputBasePath,
105
+ })
106
+ console.log(`Transcript written to ${outputBasePath}.txt`)
107
+ console.log(`Segments written to ${outputBasePath}.json`)
108
+ console.log(result.text)
109
+ },
110
+ )
111
+ .command(
112
+ 'detect-speech <input>',
113
+ 'Show detected speech segments for a file',
114
+ (command) =>
115
+ command
116
+ .positional('input', {
117
+ type: 'string',
118
+ describe: 'Input audio/video file',
119
+ })
120
+ .option('start', {
121
+ type: 'number',
122
+ describe: 'Start time in seconds',
123
+ })
124
+ .option('end', {
125
+ type: 'number',
126
+ describe: 'End time in seconds',
127
+ }),
128
+ async (argv) => {
129
+ await ensureFfmpegAvailable()
130
+ const segments = await detectSpeechSegmentsForFile({
131
+ inputPath: String(argv.input),
132
+ start: typeof argv.start === 'number' ? argv.start : undefined,
133
+ end: typeof argv.end === 'number' ? argv.end : undefined,
134
+ })
135
+ console.log(JSON.stringify(segments, null, 2))
136
+ },
137
+ )
138
+ .demandCommand(1)
139
+ .strict()
140
+ .help()
141
+
142
+ await parser.parseAsync()
143
+ }
144
+
145
+ main().catch((error) => {
146
+ console.error(
147
+ `[error] ${error instanceof Error ? error.message : String(error)}`,
148
+ )
149
+ process.exit(1)
150
+ })
package/package.json CHANGED
@@ -1,10 +1,42 @@
1
1
  {
2
2
  "name": "eprec",
3
- "version": "0.0.1",
4
- "description": "OIDC trusted publishing setup package for eprec",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
3
+ "type": "module",
4
+ "version": "1.0.1",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/epicweb-dev/eprec"
9
+ },
10
+ "scripts": {
11
+ "format": "prettier --write .",
12
+ "test": "bun test process-course utils.test.ts",
13
+ "test:e2e": "bun test e2e",
14
+ "test:all": "bun test",
15
+ "validate": "bun run test"
16
+ },
17
+ "bin": {
18
+ "eprec": "./cli.ts"
19
+ },
20
+ "files": [
21
+ "cli.ts",
22
+ "process-course/**",
23
+ "process-course-video.ts",
24
+ "speech-detection.ts",
25
+ "utils.ts",
26
+ "whispercpp-transcribe.ts"
27
+ ],
28
+ "prettier": "@epic-web/config/prettier",
29
+ "devDependencies": {
30
+ "@epic-web/config": "^1.21.3",
31
+ "@types/bun": "latest",
32
+ "@types/yargs": "^17.0.35",
33
+ "prettier": "^3.8.1"
34
+ },
35
+ "peerDependencies": {
36
+ "typescript": "^5"
37
+ },
38
+ "dependencies": {
39
+ "onnxruntime-node": "^1.23.2",
40
+ "yargs": "^18.0.0"
41
+ }
10
42
  }