Skip to content

Commit 5f1c152

Browse files
committed
Add more examples
1 parent 02d1f68 commit 5f1c152

4 files changed

Lines changed: 52 additions & 3 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
/deno.lock
33
/dist
44
/cov_profile
5-
/cov_profile.lcov
5+
/cov_profile.lcov
6+
/examples/jfk.wav*
7+
/examples/node_modules
8+
/examples/package.json
9+
/examples/package-lock.json

examples/whisper.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
npm install @teaxyz/lib
3+
node whisper.js
4+
*/
5+
6+
const { porcelain } = require("@teaxyz/lib")
7+
const https = require("node:https")
8+
const { run } = porcelain
9+
const fs = require("node:fs")
10+
11+
const url = 'https://github.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav'
12+
13+
const fetch = new Promise(done =>
14+
https.get(url, rsp =>
15+
rsp.pipe(fs.createWriteStream("jfk.wav")).on('finish', done)))
16+
17+
fetch.then(() =>run("whisper.cpp jfk.wav"))

examples/whisper.mjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
npm install @teaxyz/lib
3+
node whisper.mjs
4+
*/
5+
6+
import { porcelain } from "@teaxyz/lib"
7+
import https from "node:https"
8+
const { run } = porcelain
9+
import fs from "node:fs"
10+
11+
const url = 'https://raw.githubusercontent.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav'
12+
13+
await new Promise(done =>
14+
https.get(url, rsp =>
15+
rsp.pipe(fs.createWriteStream("jfk.wav")).on('finish', done)))
16+
17+
await run("whisper.cpp jfk.wav")

examples/whisper.ts

100644100755
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env --unstable --allow-net
22

3+
/*
4+
sh <(curl tea.xyz) https://raw.githubusercontent.com/teaxyz/lib/main/examples/whisper.ts
5+
*/
6+
37
import { porcelain } from "https://raw.github.com/teaxyz/lib/v0/mod.ts"
8+
import { green } from "https://deno.land/std/fmt/colors.ts"
49
const { run } = porcelain
510

6-
const url = 'https://raw.githubusercontent.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav'
11+
const url = 'https://github.com/ggerganov/whisper.cpp/raw/master/samples/jfk.wav'
712
const rsp = await fetch(url)
813
await Deno.writeFile("jfk.wav", rsp.body!)
914

10-
await run("whisper.cpp jfk.wav")
15+
await run("whisper.cpp jfk.wav --output-json")
16+
17+
const txt = Deno.readTextFileSync("jfk.wav.json")
18+
const json = JSON.parse(txt)
19+
20+
console.log()
21+
console.log(green(json.transcription[0].text.trim()))

0 commit comments

Comments
 (0)