-
-
- {selectedModel != loadedModel && progress == 0 && (
-
-
+ >
);
};
diff --git a/playground/src/components/gearIcon.tsx b/playground/src/components/gearIcon.tsx
new file mode 100644
index 0000000..db17e06
--- /dev/null
+++ b/playground/src/components/gearIcon.tsx
@@ -0,0 +1,141 @@
+const GearIcon = () => {
+ return (
+
+ );
+};
+
+export default GearIcon;
diff --git a/playground/src/components/languageDropdown.tsx b/playground/src/components/languageDropdown.tsx
new file mode 100644
index 0000000..ee3467f
--- /dev/null
+++ b/playground/src/components/languageDropdown.tsx
@@ -0,0 +1,189 @@
+import React, { useState } from "react";
+import { ConfigOptions } from "./configModal";
+
+const AvailableLanguages = {
+ en: "English",
+ zh: "Chinese",
+ de: "German",
+ es: "Spanish",
+ ru: "Russian",
+ ko: "Korean",
+ fr: "French",
+ ja: "Japanese",
+ pt: "Portuguese",
+ tr: "Turkish",
+ pl: "Polish",
+ ca: "Catalan",
+ nl: "Dutch",
+ ar: "Arabic",
+ sv: "Swedish",
+ it: "Italian",
+ id: "Indonesian",
+ hi: "Hindi",
+ fi: "Finnish",
+ vi: "Vietnamese",
+ he: "Hebrew",
+ uk: "Ukrainian",
+ el: "Greek",
+ ms: "Malay",
+ cs: "Czech",
+ ro: "Romanian",
+ da: "Danish",
+ hu: "Hungarian",
+ ta: "Tamil",
+ no: "Norwegian",
+ th: "Thai",
+ ur: "Urdu",
+ hr: "Croatian",
+ bg: "Bulgarian",
+ lt: "Lithuanian",
+ la: "Latin",
+ mi: "Maori",
+ ml: "Malayalam",
+ cy: "Welsh",
+ sk: "Slovak",
+ te: "Telugu",
+ fa: "Persian",
+ lv: "Latvian",
+ bn: "Bengali",
+ sr: "Serbian",
+ az: "Azerbaijani",
+ sl: "Slovenian",
+ kn: "Kannada",
+ et: "Estonian",
+ mk: "Macedonian",
+ br: "Breton",
+ eu: "Basque",
+ is: "Icelandic",
+ hy: "Armenian",
+ ne: "Nepali",
+ mn: "Mongolian",
+ bs: "Bosnian",
+ kk: "Kazakh",
+ sq: "Albanian",
+ sw: "Swahili",
+ gl: "Galician",
+ mr: "Marathi",
+ pa: "Punjabi",
+ si: "Sinhala",
+ km: "Khmer",
+ sn: "Shona",
+ yo: "Yoruba",
+ so: "Somali",
+ af: "Afrikaans",
+ oc: "Occitan",
+ ka: "Georgian",
+ be: "Belarusian",
+ tg: "Tajik",
+ sd: "Sindhi",
+ gu: "Gujarati",
+ am: "Amharic",
+ yi: "Yiddish",
+ lo: "Lao",
+ uz: "Uzbek",
+ fo: "Faroese",
+ ht: "Haitian creole",
+ ps: "Pashto",
+ tk: "Turkmen",
+ nn: "Nynorsk",
+ mt: "Maltese",
+ sa: "Sanskrit",
+ lb: "Luxembourgish",
+ my: "Myanmar",
+ bo: "Tibetan",
+ tl: "Tagalog",
+ mg: "Malagasy",
+ as: "Assamese",
+ tt: "Tatar",
+ haw: "Hawaiian",
+ ln: "Lingala",
+ ha: "Hausa",
+ ba: "Bashkir",
+ jw: "Javanese",
+ su: "Sundanese",
+ yue: "Cantonese",
+};
+
+interface LanguageDropdownProps {
+ configOptions: ConfigOptions;
+ setConfigOptions: React.Dispatch
>;
+}
+
+const LanguageDropdown = (props: LanguageDropdownProps) => {
+ const [open, setOpen] = useState(false);
+ const [selectedLanguage, setSelectedLanguage] = useState(
+ props.configOptions.language
+ );
+
+ const toggleOpen = () => setOpen((prev) => !prev);
+
+ const selectLanguage = (lang: string) => {
+ props.setConfigOptions((prev: ConfigOptions) => ({
+ ...prev,
+ language: lang,
+ }));
+ setSelectedLanguage(lang);
+ setOpen(false);
+ };
+
+ return (
+
+
+
+
+ {selectedLanguage || "Select a language"}
+
+
+
+
+
+
+ {open && (
+
+ )}
+
+ );
+};
+
+export default LanguageDropdown;
diff --git a/playground/src/components/layout.tsx b/playground/src/components/layout.tsx
index 1363817..df170f9 100644
--- a/playground/src/components/layout.tsx
+++ b/playground/src/components/layout.tsx
@@ -2,7 +2,7 @@ import Head from "next/head";
import { Toaster } from "react-hot-toast";
import React from "react";
-export const siteTitle = "AI Playground";
+export const siteTitle = "Whisper Turbo";
type LayoutProps = {
children: React.ReactNode;
diff --git a/playground/src/components/modal.tsx b/playground/src/components/modal.tsx
index f77a3ed..49b23d4 100644
--- a/playground/src/components/modal.tsx
+++ b/playground/src/components/modal.tsx
@@ -5,8 +5,6 @@ const WebGPUModal = () => {
const [hasWebGPU, setHasWebGPU] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(true);
- const myRef = React.useRef(null);
-
useEffect(() => {
//@ts-ignore
if (!navigator.gpu) {
diff --git a/playground/src/components/suppressSelector.tsx b/playground/src/components/suppressSelector.tsx
new file mode 100644
index 0000000..47a643d
--- /dev/null
+++ b/playground/src/components/suppressSelector.tsx
@@ -0,0 +1,48 @@
+import React, { useState } from "react";
+import { ConfigOptions } from "./configModal";
+
+interface SuppressComponentProps {
+ configOptions: ConfigOptions;
+ setConfigOptions: React.Dispatch>;
+}
+
+const SuppressComponent = (props: SuppressComponentProps) => {
+ const [checkedState, setCheckedState] = useState({
+ suppress_non_speech: props.configOptions.suppress_non_speech
+ });
+
+ const handleOnChange = (event: React.ChangeEvent) => {
+ setCheckedState({
+ ...checkedState,
+ [event.target.name]: event.target.checked
+ });
+
+ props.setConfigOptions({
+ ...props.configOptions,
+ suppress_non_speech: event.target.checked
+ });
+ };
+
+ return (
+
+ );
+};
+
+export default SuppressComponent;
diff --git a/playground/src/components/taskSelector.tsx b/playground/src/components/taskSelector.tsx
new file mode 100644
index 0000000..8cb9366
--- /dev/null
+++ b/playground/src/components/taskSelector.tsx
@@ -0,0 +1,78 @@
+import React, { useState } from "react";
+import { ConfigOptions } from "./configModal";
+import { Task } from "whisper-webgpu";
+
+interface TaskComponentProps {
+ configOptions: ConfigOptions;
+ setConfigOptions: React.Dispatch>;
+}
+
+const TaskComponent = (props: TaskComponentProps) => {
+ let state = {
+ translate: props.configOptions.task === Task.Translate,
+ transcribe: props.configOptions.task === Task.Transcribe,
+ };
+
+ const [checkedState, setCheckedState] = useState(state);
+
+ const handleOnChange = (event: React.ChangeEvent) => {
+ setCheckedState({
+ ...checkedState,
+ [event.target.name]: event.target.checked,
+ });
+ if (event.target.name === "translate")
+ setCheckedState({
+ translate: event.target.checked,
+ transcribe: !event.target.checked,
+ });
+ if (event.target.name === "transcribe")
+ setCheckedState({
+ translate: !event.target.checked,
+ transcribe: event.target.checked,
+ });
+ props.setConfigOptions((prev: ConfigOptions) => ({
+ ...prev,
+ task:
+ event.target.name === "translate"
+ ? Task.Translate
+ : Task.Transcribe,
+ }));
+ };
+
+ return (
+
+ );
+};
+
+export default TaskComponent;
diff --git a/playground/src/pages/index.tsx b/playground/src/pages/index.tsx
index be7f354..b2ce1c7 100644
--- a/playground/src/pages/index.tsx
+++ b/playground/src/pages/index.tsx
@@ -2,16 +2,14 @@ import type { NextPage } from "next";
import { VT323 } from "@next/font/google";
import { useState } from "react";
import Layout from "../components/layout";
-import ControlPanel, {
- TSSegment,
- TSTranscript,
-} from "../components/controlPanel";
import WebGPUModal from "../components/modal";
+import { Segment } from "whisper-turbo";
+import ControlPanel, { Transcript } from "../components/controlPanel";
const vt = VT323({ weight: "400", display: "swap" });
const Home: NextPage = () => {
- const [transcript, setTranscript] = useState({
+ const [transcript, setTranscript] = useState({
segments: [],
});
const [downloadAvailable, setDownloadAvailable] = useState(false);
@@ -43,7 +41,7 @@ const Home: NextPage = () => {
{transcript &&
transcript.segments.map(
- (segment: TSSegment) => {
+ (segment: Segment) => {
return (
>;
+ raw_audio: boolean,
+ options: any
+ ): Promise>;
public async transcribe(
audio: Uint8Array,
raw_audio: boolean,
+ options: any,
callback: (decoded: Segment) => void
): Promise>;
- public async transcribe(
+ async transcribe(
audio: Uint8Array,
raw_audio: boolean,
+ options: any,
callback?: (decoded: Segment) => void
- ): Promise> {
+ ): Promise> {
if (this.session == null) {
return Result.err(new Error("Session not initialized"));
}
if (callback) {
if (this.session instanceof Session) {
- return await this.session.stream(audio, raw_audio, callback);
+ return await this.session.stream(
+ audio,
+ raw_audio,
+ options,
+ callback
+ );
} else {
return await this.session!.stream(
audio,
raw_audio,
+ options,
Comlink.proxy(callback)
);
}
} else {
- return await this.session!.run(audio);
+ return await this.session!.run(audio, options);
}
}
diff --git a/src/session.worker.ts b/src/session.worker.ts
index 9425bd5..0a37946 100644
--- a/src/session.worker.ts
+++ b/src/session.worker.ts
@@ -62,8 +62,9 @@ export class Session {
}
public async run(
- audio: Uint8Array
- ): Promise> {
+ audio: Uint8Array,
+ options: any
+ ): Promise> {
if (!this.whisperSession) {
return Result.err(
new Error(
@@ -72,12 +73,13 @@ export class Session {
);
}
- return Result.ok(await this.whisperSession.run(audio));
+ return Result.ok(await this.whisperSession.run(audio, options));
}
public async stream(
audio: Uint8Array,
raw_audio: boolean,
+ options: any,
callback: (decoded: whisper.Segment) => void
): Promise> {
if (!this.whisperSession) {
@@ -89,7 +91,12 @@ export class Session {
}
return Result.ok(
- await this.whisperSession.stream(audio, raw_audio, callback)
+ await this.whisperSession.stream(
+ audio,
+ raw_audio,
+ options,
+ callback
+ )
);
}
}