From dd7f932516603da05a60b7c3abec9eb7b8041fcb Mon Sep 17 00:00:00 2001 From: an-lee Date: Mon, 14 Oct 2024 11:23:06 +0800 Subject: [PATCH] Improve importing resources (#1120) * compress video before import * Fix UI * compress audio before importing * fix * save recording as mp3 to save disk space --- enjoy/src/i18n/en.json | 4 +- enjoy/src/i18n/zh-CN.json | 4 +- enjoy/src/main/db/models/audio.ts | 70 +++++++++++-------- enjoy/src/main/db/models/recording.ts | 13 ++-- enjoy/src/main/db/models/video.ts | 70 +++++++++++-------- enjoy/src/main/downloader.ts | 6 +- enjoy/src/main/ffmpeg.ts | 64 +++++++++++++++++ .../audios/audible-books-segment.tsx | 6 +- .../components/chats/chat-user-message.tsx | 4 +- .../media-current-recording.tsx | 2 +- .../media-bottom-panel/media-waveform.tsx | 2 +- .../media-left-panel/media-recordings.tsx | 2 +- .../media-transcription-read-button.tsx | 2 +- .../media-caption-actions.tsx | 4 +- .../components/messages/assistant-message.tsx | 2 +- .../videos/youtube-videos-segment.tsx | 6 +- .../hooks/use-pronunciation-assessments.tsx | 3 +- 17 files changed, 182 insertions(+), 82 deletions(-) diff --git a/enjoy/src/i18n/en.json b/enjoy/src/i18n/en.json index 28207f3b..ecbbce5e 100644 --- a/enjoy/src/i18n/en.json +++ b/enjoy/src/i18n/en.json @@ -309,7 +309,9 @@ "welcomeBack": "Welcome back! {{name}}", "print": "Print", "download": "Download", - "downloading": "Downloading {{file}}", + "downloadingFile": "Downloading {{file}}", + "downloading": "Downloading", + "importing": "Importing", "downloadedSuccessfully": "Downloaded successfully", "downloadFailed": "Download failed", "chooseAIModelDependingOnYourHardware": "Choose AI Model depending on your hardware.", diff --git a/enjoy/src/i18n/zh-CN.json b/enjoy/src/i18n/zh-CN.json index a807f92c..ee7baf82 100644 --- a/enjoy/src/i18n/zh-CN.json +++ b/enjoy/src/i18n/zh-CN.json @@ -309,7 +309,9 @@ "welcomeBack": "欢迎回来, {{name}}", "print": "打印", "download": "下载", - "downloading": "正在下载 {{file}}", + "downloadingFile": "正在下载 {{file}}", + "downloading": "正在下载", + "importing": "正在导入", "downloadedSuccessfully": "下载成功", "downloadFailed": "下载失败", "chooseAIModelDependingOnYourHardware": "根据您的硬件选择合适的 AI 模型, 以便语音转文本服务正常工作", diff --git a/enjoy/src/main/db/models/audio.ts b/enjoy/src/main/db/models/audio.ts index cbbf89c9..f2c13367 100644 --- a/enjoy/src/main/db/models/audio.ts +++ b/enjoy/src/main/db/models/audio.ts @@ -2,7 +2,6 @@ import { AfterCreate, AfterUpdate, AfterDestroy, - BeforeCreate, BelongsTo, Table, Column, @@ -36,8 +35,6 @@ import startCase from "lodash/startCase"; import { v5 as uuidv5 } from "uuid"; import FfmpegWrapper from "@main/ffmpeg"; -const SIZE_LIMIT = 1024 * 1024 * 50; // 50MB - const logger = log.scope("db/models/audio"); @Table({ @@ -127,7 +124,13 @@ export class Audio extends Model