From 52c94afa3fc27150fa64f3228a83ded79d60797e Mon Sep 17 00:00:00 2001 From: an-lee Date: Wed, 14 Aug 2024 16:36:28 +0800 Subject: [PATCH] Improve assessment (#967) * add zh-HK * refactor assessment form * refactor assessment recorder * share recording from assessment list * fix post recording segment --- enjoy/src/constants/languages.json | 4 + .../components/posts/post-recording.tsx | 1 + .../pronunciation-assessment-card.tsx | 19 +- .../pronunciation-assessment-form.tsx | 215 ++++++++++-------- .../pages/pronunciation-assessments/index.tsx | 63 ++++- 5 files changed, 202 insertions(+), 100 deletions(-) diff --git a/enjoy/src/constants/languages.json b/enjoy/src/constants/languages.json index 6b2508f97..3d0eda238 100644 --- a/enjoy/src/constants/languages.json +++ b/enjoy/src/constants/languages.json @@ -11,6 +11,10 @@ "code": "zh-CN", "name": "简体中文" }, + { + "code": "zh-HK", + "name": "粤语" + }, { "code": "ja-JP", "name": "日本語" diff --git a/enjoy/src/renderer/components/posts/post-recording.tsx b/enjoy/src/renderer/components/posts/post-recording.tsx index 54185fec3..73789dd33 100644 --- a/enjoy/src/renderer/components/posts/post-recording.tsx +++ b/enjoy/src/renderer/components/posts/post-recording.tsx @@ -15,6 +15,7 @@ export const PostRecording = (props: { const fetchSegment = async () => { if (segment) return; + if (!recording.targetId) return; webApi .mineSegments({ diff --git a/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-card.tsx b/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-card.tsx index 08ae10a8a..bfbbc8558 100644 --- a/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-card.tsx +++ b/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-card.tsx @@ -17,8 +17,14 @@ export const PronunciationAssessmentCard = (props: { pronunciationAssessment: PronunciationAssessmentType; onSelect: (assessment: PronunciationAssessmentType) => void; onDelete: (assessment: PronunciationAssessmentType) => void; + onSharing: (recording: RecordingType) => void; }) => { - const { pronunciationAssessment: assessment, onSelect, onDelete } = props; + const { + pronunciationAssessment: assessment, + onSelect, + onDelete, + onSharing, + } = props; return (
-
+
+
diff --git a/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-form.tsx b/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-form.tsx index 9de7f7777..4a994b944 100644 --- a/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-form.tsx +++ b/enjoy/src/renderer/components/pronunciation-assessments/pronunciation-assessment-form.tsx @@ -26,10 +26,18 @@ import { LANGUAGES } from "@/constants"; import { z } from "zod"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { LoaderIcon, MicIcon, SquareIcon } from "lucide-react"; -import WaveSurfer from "wavesurfer.js"; -import RecordPlugin from "wavesurfer.js/dist/plugins/record"; +import { + CheckIcon, + LoaderIcon, + MicIcon, + PauseIcon, + PlayIcon, + SquareIcon, + XIcon, +} from "lucide-react"; import { usePronunciationAssessments } from "@/renderer/hooks"; +import { useAudioRecorder } from "react-audio-voice-recorder"; +import { LiveAudioVisualizer } from "react-audio-visualize"; const pronunciationAssessmentSchema = z.object({ file: z.instanceof(FileList).optional(), @@ -135,6 +143,7 @@ export const PronunciationAssessmentForm = () => { render={() => ( { render={({ field }) => ( { render={({ field }) => ( {t("language")} - @@ -216,6 +230,7 @@ export const PronunciationAssessmentForm = () => { {t("referenceText")}