-
Notifications
You must be signed in to change notification settings - Fork 25
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
Showing
9 changed files
with
111 additions
and
121 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,81 +1,69 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request_target: | ||
push: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
pull-requests: write | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
merge_group: {} | ||
|
||
jobs: | ||
job1: | ||
name: Check Not Allowed File Changes | ||
lint: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
markdown_change: ${{ steps.filter_markdown.outputs.change }} | ||
markdown_files: ${{ steps.filter_markdown.outputs.change_files }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check Not Allowed File Changes | ||
uses: dorny/paths-filter@v2 | ||
id: filter_not_allowed | ||
with: | ||
list-files: json | ||
filters: | | ||
change: | ||
- 'package-lock.json' | ||
- 'yarn.lock' | ||
- 'pnpm-lock.yaml' | ||
# ref: https://github.com/github/docs/blob/main/.github/workflows/triage-unallowed-contributions.yml | ||
- name: Comment About Changes We Can't Accept | ||
if: ${{ steps.filter_not_allowed.outputs.change == 'true' }} | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
let workflowFailMessage = "It looks like you've modified some files that we can't accept as contributions." | ||
try { | ||
const badFilesArr = [ | ||
'package-lock.json', | ||
'yarn.lock', | ||
'pnpm-lock.yaml', | ||
] | ||
const badFiles = badFilesArr.join('\n- ') | ||
const reviewMessage = `👋 Hey there spelunker. It looks like you've modified some files that we can't accept as contributions. The complete list of files we can't accept are:\n- ${badFiles}\n\nYou'll need to revert all of the files you changed in that list using [GitHub Desktop](https://docs.github.com/en/free-pro-team@latest/desktop/contributing-and-collaborating-using-github-desktop/managing-commits/reverting-a-commit) or \`git checkout origin/main <file name>\`. Once you get those files reverted, we can continue with the review process. :octocat:\n\nMore discussion:\n- https://github.com/electron-vite/electron-vite-vue/issues/192` | ||
createdComment = await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.number, | ||
body: reviewMessage, | ||
}) | ||
workflowFailMessage = `${workflowFailMessage} Please see ${createdComment.data.html_url} for details.` | ||
} catch(err) { | ||
console.log("Error creating comment.", err) | ||
} | ||
core.setFailed(workflowFailMessage) | ||
- name: Check Not Linted Markdown | ||
if: ${{ always() }} | ||
uses: dorny/paths-filter@v2 | ||
id: filter_markdown | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
list-files: shell | ||
filters: | | ||
change: | ||
- added|modified: '*.md' | ||
node-version: 18 | ||
cache: pnpm | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Lint | ||
run: pnpm run lint | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- os: macos-latest | ||
node_version: 18 | ||
- os: windows-latest | ||
node_version: 18 | ||
|
||
job2: | ||
name: Lint Markdown | ||
runs-on: ubuntu-latest | ||
needs: job1 | ||
if: ${{ always() && needs.job1.outputs.markdown_change == 'true' }} | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
- name: Set git to use LF | ||
run: | | ||
git config --global core.autocrlf false | ||
git config --global core.eol lf | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v2 | ||
|
||
- name: Set node ${{ matrix.node_version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
node-version: ${{ matrix.node_version }} | ||
cache: pnpm | ||
|
||
- run: corepack enable | ||
|
||
- name: Install | ||
run: pnpm i | ||
|
||
- name: Lint markdown | ||
run: npx markdownlint-cli ${{ needs.job1.outputs.markdown_files }} --ignore node_modules | ||
- name: Test | ||
run: pnpm run test |
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 |
---|---|---|
|
@@ -27,4 +27,5 @@ dist-electron | |
|
||
lib | ||
public/resources/*addon.node | ||
public/resources/*onnx | ||
public/resources/*onnx | ||
test/**/ggml-*.bin |
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import got from "got" | ||
import fs from "node:fs" | ||
import path from "node:path" | ||
import { transcribe } from "~~/whisper" | ||
|
||
const modelPath = path.resolve(__dirname, "ggml-base.bin"); | ||
|
||
function downloadModel(){ | ||
return new Promise<void>((resolve, reject) => { | ||
const modelFile = fs.createWriteStream(modelPath); | ||
got.stream("https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-base.bin") | ||
.on("downloadProgress", ({ transferred, total }) => { | ||
const progress = (100.0 * transferred / total).toFixed(2) // 当前进度 | ||
const currProgress = (transferred / 1048576).toFixed(2) // 当前下了多少 | ||
console.log("data", progress, currProgress, total / 1048576) | ||
}) | ||
.pipe(modelFile).on("finish", ()=>{ | ||
console.log("downloaded") | ||
modelFile.close(); | ||
resolve() | ||
}) | ||
.on("error", (err)=>{ | ||
console.error(err) | ||
modelFile.close(); | ||
fs.unlinkSync(modelPath) | ||
reject() | ||
}) | ||
}) | ||
} | ||
|
||
beforeEach(async () => { | ||
if(!fs.existsSync(modelPath)) { | ||
try { | ||
await downloadModel() | ||
}catch(e) { | ||
if(fs.existsSync(modelPath)) { | ||
fs.unlinkSync(modelPath) | ||
} | ||
} | ||
} | ||
}, 100000) | ||
|
||
describe("whisper", () => { | ||
it("transcribe ", async () => { | ||
const wavFilePath = path.resolve(__dirname, "./jfk.wav"); | ||
const result = await transcribe(modelPath, wavFilePath) | ||
expect(result.length).toBe(2) | ||
}) | ||
}) |
Binary file not shown.
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