Macos support whisper cpp (#1186)

* arm64 macos support whisper.cpp

* add whisper binary for x64 macos
This commit is contained in:
an-lee
2024-11-18 12:00:18 +08:00
committed by GitHub
parent 9d254fd829
commit c23b73f034
8 changed files with 14158 additions and 2 deletions

View File

@@ -60,7 +60,7 @@ test.afterAll(async () => {
await electronApp.close();
});
test("validate echogarden recognition", async () => {
test("validate echogarden recognition by whisper", async () => {
const res = await page.evaluate(() => {
return window.__ENJOY_APP__.echogarden.check({
engine: "whisper",
@@ -76,6 +76,20 @@ test("validate echogarden recognition", async () => {
expect(res.success).toBeTruthy();
});
test("validate echogarden recognition by whisper.cpp", async () => {
const res = await page.evaluate(() => {
return window.__ENJOY_APP__.echogarden.check({
engine: "whisper.cpp",
whisperCpp: {
model: "tiny.en",
language: "en",
},
});
});
console.info(res.log);
expect(res.success).toBeTruthy();
});
test("valid ffmpeg command", async () => {
const res = await page.evaluate(() => {
return window.__ENJOY_APP__.ffmpeg.check();

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -68,6 +68,12 @@ class EchogardenWrapper {
// Add temporary unhandledRejection listener
process.on("unhandledRejection", handler);
// Set the whisper executable path for macOS
if (process.platform === "darwin") {
options.whisperCpp = options.whisperCpp || {};
options.whisperCpp.executablePath = path.join(__dirname, "lib", "whisper", "main");
}
// Call the original recognize function
Echogarden.recognize(sampleFile, options)
.then((result) => {
@@ -97,6 +103,9 @@ class EchogardenWrapper {
whisper: {
model: "tiny.en",
},
whisperCpp: {
model: "tiny.en",
}
}
) {
const sampleFile = path.join(__dirname, "samples", "jfk.wav");

View File

@@ -116,7 +116,6 @@ export const EchogardenSttSettings = (props: {
<SelectContent>
<SelectItem value="whisper">Whisper</SelectItem>
<SelectItem
disabled={platformInfo?.platform === "darwin"}
value="whisper.cpp"
>
Whisper.cpp

View File

@@ -45,6 +45,12 @@ export default defineConfig((env) => {
pluginHotRestart("restart"),
viteStaticCopy({
targets: [
{
src: `lib/whisper.cpp/${
process.env.PACKAGE_OS_ARCH || os.arch()
}/${os.platform()}/*`,
dest: "lib/whisper",
},
{
src: `lib/youtubedr/${
process.env.PACKAGE_OS_ARCH || os.arch()