Skip to content

Commit d2c32d3

Browse files
authored
Fix transcription (#1137)
* upgrade deps * fix generate transcription * validate transcription before download from online
1 parent ae4d245 commit d2c32d3

File tree

5 files changed

+173
-129
lines changed

5 files changed

+173
-129
lines changed

1000-hours/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"markdown-it-sub": "^2.0.0",
99
"markdown-it-sup": "^2.0.0",
1010
"mermaid": "^11.3.0",
11-
"sass": "^1.80.1",
11+
"sass": "^1.80.3",
1212
"vitepress": "^1.4.1",
1313
"vitepress-plugin-mermaid": "^2.0.17",
1414
"vue": "^3.5.12"

1000h-portal/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"devDependencies": {
2020
"autoprefixer": "^10.4.20",
2121
"postcss": "^8.4.47",
22-
"sass": "^1.80.1",
22+
"sass": "^1.80.3",
2323
"tailwindcss": "^3.4.14"
2424
}
2525
}

enjoy/package.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
"@types/fluent-ffmpeg": "^2.1.26",
5050
"@types/html-to-text": "^9.0.4",
5151
"@types/intl-tel-input": "^18.1.4",
52-
"@types/lodash": "^4.17.10",
52+
"@types/lodash": "^4.17.12",
5353
"@types/mark.js": "^8.11.12",
5454
"@types/mustache": "^4.2.5",
55-
"@types/node": "^22.7.6",
55+
"@types/node": "^22.7.7",
5656
"@types/prop-types": "^15.7.13",
5757
"@types/rails__actioncable": "^6.1.11",
5858
"@types/react": "^18.3.11",
@@ -61,14 +61,14 @@
6161
"@types/unzipper": "^0.10.10",
6262
"@types/validator": "^13.12.2",
6363
"@types/wavesurfer.js": "^6.0.12",
64-
"@typescript-eslint/eslint-plugin": "^8.9.0",
65-
"@typescript-eslint/parser": "^8.9.0",
66-
"@vitejs/plugin-react": "^4.3.2",
64+
"@typescript-eslint/eslint-plugin": "^8.10.0",
65+
"@typescript-eslint/parser": "^8.10.0",
66+
"@vitejs/plugin-react": "^4.3.3",
6767
"autoprefixer": "^10.4.20",
6868
"electron": "^33.0.1",
6969
"electron-devtools-installer": "^3.2.0",
7070
"electron-playwright-helpers": "^1.7.1",
71-
"eslint": "^9.12.0",
71+
"eslint": "^9.13.0",
7272
"eslint-import-resolver-typescript": "^3.6.3",
7373
"eslint-plugin-import": "^2.31.0",
7474
"flora-colossus": "^2.0.0",
@@ -139,7 +139,7 @@
139139
"dayjs": "^1.11.13",
140140
"decamelize": "^6.0.0",
141141
"decamelize-keys": "^2.0.1",
142-
"echogarden": "^1.8.5",
142+
"echogarden": "^1.8.7",
143143
"electron-context-menu": "^4.0.4",
144144
"electron-log": "^5.2.0",
145145
"electron-settings": "^4.0.4",
@@ -149,7 +149,7 @@
149149
"fs-extra": "^11.2.0",
150150
"html-to-text": "^9.0.5",
151151
"https-proxy-agent": "^7.0.5",
152-
"i18next": "^23.16.0",
152+
"i18next": "^23.16.1",
153153
"intl-tel-input": "^24.6.0",
154154
"js-md5": "^0.8.3",
155155
"langchain": "^0.3.2",
@@ -160,17 +160,17 @@
160160
"microsoft-cognitiveservices-speech-sdk": "^1.41.0",
161161
"mustache": "^4.2.0",
162162
"next-themes": "^0.3.0",
163-
"openai": "^4.67.3",
163+
"openai": "^4.68.1",
164164
"pitchfinder": "^2.3.2",
165165
"postcss": "^8.4.47",
166166
"proxy-agent": "^6.4.0",
167167
"react": "^18.3.1",
168-
"react-activity-calendar": "^2.6.2",
168+
"react-activity-calendar": "^2.6.3",
169169
"react-audio-visualize": "^1.2.0",
170170
"react-audio-voice-recorder": "^2.2.0",
171171
"react-dom": "^18.3.1",
172172
"react-frame-component": "^5.2.7",
173-
"react-hook-form": "^7.53.0",
173+
"react-hook-form": "^7.53.1",
174174
"react-hotkeys-hook": "^4.5.1",
175175
"react-i18next": "^15.0.3",
176176
"react-markdown": "^9.0.1",
@@ -189,7 +189,7 @@
189189
"umzug": "^3.8.2",
190190
"unzipper": "^0.12.3",
191191
"update-electron-app": "^3.0.0",
192-
"wavesurfer.js": "^7.8.6",
192+
"wavesurfer.js": "^7.8.7",
193193
"zod": "^3.23.8",
194194
"zod-to-json-schema": "^3.23.3"
195195
}

enjoy/src/renderer/hooks/use-transcriptions.tsx

+24-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ export const useTranscriptions = (media: AudioType | VideoType) => {
9494
items: 10,
9595
});
9696
if (result.transcriptions.length) {
97-
return result.transcriptions[0];
97+
for (const tr of result.transcriptions) {
98+
if (validateTranscription(tr)) {
99+
return tr;
100+
} else {
101+
console.warn(`Invalid transcription: ${tr.id}`);
102+
}
103+
}
98104
} else {
99105
return null;
100106
}
@@ -115,7 +121,7 @@ export const useTranscriptions = (media: AudioType | VideoType) => {
115121
originalText,
116122
language = learningLanguage,
117123
service = sttEngine,
118-
model,
124+
model: whisperModel,
119125
isolate = false,
120126
} = params || {};
121127
setService(service);
@@ -138,6 +144,7 @@ export const useTranscriptions = (media: AudioType | VideoType) => {
138144
{
139145
targetId: media.id,
140146
targetType: media.mediaType,
147+
model: whisperModel,
141148
originalText,
142149
language,
143150
service,
@@ -254,6 +261,21 @@ export const useTranscriptions = (media: AudioType | VideoType) => {
254261
return timeline;
255262
};
256263

264+
const validateTranscription = (transcription: TranscriptionType) => {
265+
if (!transcription) return;
266+
267+
const { timeline, transcript } = transcription.result;
268+
if (!timeline || !transcript) {
269+
return false;
270+
}
271+
272+
if (timeline[0]?.type !== "sentence") {
273+
return false;
274+
}
275+
276+
return true;
277+
};
278+
257279
/*
258280
* find or create transcription
259281
*/

0 commit comments

Comments
 (0)