From 1ac3768468d871c43c13c7f11ef3244e6858a423 Mon Sep 17 00:00:00 2001 From: jialin Date: Fri, 29 Nov 2024 21:05:55 +0800 Subject: [PATCH] fix: speech size 0, do not create url --- .../speech-content/audio-player.tsx | 29 ++++++++++++------ .../speech-content/hooks/use-wavesurfer.ts | 17 ++++++++++ src/components/speech-content/ih.mp4 | Bin 32772 -> 0 bytes src/components/speech-content/speech-item.tsx | 21 +++++++++++-- .../speech-content/styles/index.less | 1 + src/pages/playground/apis/index.ts | 2 +- .../playground/components/ground-stt.tsx | 12 ++++++-- .../playground/components/ground-tts.tsx | 13 ++++++-- 8 files changed, 77 insertions(+), 18 deletions(-) delete mode 100644 src/components/speech-content/ih.mp4 diff --git a/src/components/speech-content/audio-player.tsx b/src/components/speech-content/audio-player.tsx index 685c37c0..cef16354 100644 --- a/src/components/speech-content/audio-player.tsx +++ b/src/components/speech-content/audio-player.tsx @@ -13,24 +13,35 @@ interface AudioPlayerProps { ref?: any; height?: number; width?: number; + onReady?: () => void; + onClick?: (value: number) => void; } const AudioPlayer: React.FC = forwardRef((props, ref) => { const { autoplay, audioUrl, speed = 1, ...rest } = props; const container = useRef(null); - const { createWavesurfer, play, pause, destroyWavesurfer, wavesurfer } = - useWavesurfer({ - container, - autoplay: autoplay, - url: audioUrl, - audioRate: speed, - ...rest - }); + const { + createWavesurfer, + play, + pause, + duration, + destroyWavesurfer, + wavesurfer + } = useWavesurfer({ + container, + autoplay: autoplay, + url: audioUrl, + audioRate: speed, + onReady: props.onReady, + onClick: props.onClick, + ...rest + }); useImperativeHandle(ref, () => { return { play, - pause + pause, + duration }; }); diff --git a/src/components/speech-content/hooks/use-wavesurfer.ts b/src/components/speech-content/hooks/use-wavesurfer.ts index 90ba007b..1519e942 100644 --- a/src/components/speech-content/hooks/use-wavesurfer.ts +++ b/src/components/speech-content/hooks/use-wavesurfer.ts @@ -11,6 +11,8 @@ interface Options { barRadius?: number; autoplay?: boolean; audioRate?: number; + onReady?: () => void; + onClick: (value: any) => void; } const useWavesurfer = (options: Options) => { const wavesurfer = useRef(null); @@ -37,6 +39,13 @@ const useWavesurfer = (options: Options) => { cursorWidth: 0, ...rest }); + wavesurfer.current?.on('ready', () => { + options.onReady?.(); + }); + + wavesurfer.current?.on('click', (value) => { + options.onClick?.(value); + }); }; const destroyWavesurfer = () => { @@ -51,6 +60,13 @@ const useWavesurfer = (options: Options) => { } }; + const duration = () => { + if (wavesurfer.current) { + return wavesurfer.current.getDuration(); + } + return 0; + }; + const pause = () => { if (wavesurfer.current) { wavesurfer.current.pause(); @@ -62,6 +78,7 @@ const useWavesurfer = (options: Options) => { play, pause, wavesurfer, + duration, destroyWavesurfer }; }; diff --git a/src/components/speech-content/ih.mp4 b/src/components/speech-content/ih.mp4 deleted file mode 100644 index 7e684ebd4ed1b51922deb380aef612909499b0c8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32772 zcmeIZcU%<7*XUh6Ip;jXkU^55B4W;pIqjMg3Z@kk26Wdohjq<4M^sc4vmyv$00k6L za*jie!{nK+Te|yupXWaB`~H1D_w$(^$F8obK2`NSr_NMY9{>QdCF?h@iC7cZ6QJYA zd3ogO2mlDd5vx~kL|H2%HZBYMQC9Kv?93lu0H(VD5KI6V`0?+*j{offW&e-sA^%nL z|0_j6H@siJF7!84ICuSTKij1KSDXKlhT8pa$ImAIM?3$i`JZY-{*(CU>=qujJ`yEW z;VUE8|67D4{44h#fdeAKmWQG;r--ospRxaQqsy|emFxbM0U}p#SoNRu|8wq)SiWir zy5dDf{3Ge#61T8_@>OB$!he+iIDWLv+OTe=)4%EGk?R+&MCoCX>mz?^;NSe7%hxPM z8v1$s?C-xR-jDMS-JpYmsto^``jIP(T>o>-KQhoAKgasx&TdHZ;vbpl_`wzB`SAZa z|F~v#{F@e`dRtKX$AR*H-j8H1Uj0wjkGvnvEO7yV9kXOzc=*5h_LH4}oq(Nyoq(Ny zoq(Nyoq(Nyoq(NyoxuNb0&7?iVWI0`61IRmn>m8NP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i2)dA|A2uF|x5>upEp-)^r8MMb@IR?ne9vA)ES& z$h}1}WQh7kH0OfQJopGxU@?;8isqsdB3}wKU@p|5IzA|mjJ)eR#Qh!eu_SaIfaV$n zvB*MoS`bIHsR5Wseh{Kq{k^rif4TMtbr zkAkilNHP(5_8 = (props) => { const intl = useIntl(); const [collapsed, setCollapsed] = useState(false); const [isPlay, setIsPlay] = useState(false); - const ref = useRef(null); + const [duration, setDuration] = useState(0); + const [currentTime, setCurrentTime] = useState(0); + const ref = useRef(null); const handlePlay = () => { if (isPlay) { @@ -53,6 +56,15 @@ const SpeechItem: React.FC = (props) => { setCollapsed(!collapsed); }; + const handleReay = () => { + const duration = ref.current?.duration?.(); + setDuration(duration < 1 ? 1 : duration); + }; + + const handleOnClick = (value: number) => { + console.log('current:', value); + }; + const onDownload = () => { const url = props.audioUrl || ''; const filename = `audio-${dayjs().format('YYYYMMDDHHmmss')}.${props.format}`; @@ -75,6 +87,8 @@ const SpeechItem: React.FC = (props) => { @@ -82,9 +96,8 @@ const SpeechItem: React.FC = (props) => {
{props.format} - {/* - {props.speed}x */} + {formatTime(duration)}
= (props) => { } >