diff --git a/config/config.ts b/config/config.ts index 83b0519e..8633f558 100644 --- a/config/config.ts +++ b/config/config.ts @@ -14,7 +14,7 @@ const isProduction = env === 'production'; const t = Date.now(); export default defineConfig({ proxy: { - ...proxy('http://192.168.50.4') + ...proxy('http://192.168.50.3') }, history: { type: 'hash' diff --git a/src/components/audio-animation/index.tsx b/src/components/audio-animation/index.tsx index db9be622..2b2cb780 100644 --- a/src/components/audio-animation/index.tsx +++ b/src/components/audio-animation/index.tsx @@ -5,6 +5,7 @@ import './index.less'; interface AudioAnimationProps { width: number; height: number; + maxWidth?: number; scaleFactor?: number; maxBarCount?: number; fixedHeight?: boolean; @@ -18,6 +19,7 @@ const AudioAnimation: React.FC = (props) => { const { scaleFactor = 1.2, maxBarCount = 128, + maxWidth, fixedHeight = true, analyserData, width: initialWidth, @@ -133,12 +135,16 @@ const AudioAnimation: React.FC = (props) => { React.useEffect(() => { if (size) { - setWidth(size?.width || 0); + if (maxWidth) { + setWidth(Math.min(size.width, maxWidth)); + } else { + setWidth(size?.width || 0); + } if (!fixedHeight) { setHeight(size?.height || 0); } } - }, [size]); + }, [size, maxWidth]); useEffect(() => { if (!canvasRef.current) return; diff --git a/src/components/logs-viewer/virtual-log-list.tsx b/src/components/logs-viewer/virtual-log-list.tsx index adb386bb..61e9cb32 100644 --- a/src/components/logs-viewer/virtual-log-list.tsx +++ b/src/components/logs-viewer/virtual-log-list.tsx @@ -140,6 +140,7 @@ const LogsViewer: React.FC = forwardRef((props, ref) => { const updateContent = useCallback( (inputStr: string) => { + console.log('inputStr===', inputStr); const data = inputStr.replace(replaceLineRegex, '\n'); if (isClean(data)) { cacheDataRef.current = data; diff --git a/src/components/speech-content/speech-item.tsx b/src/components/speech-content/speech-item.tsx index 2fe83469..cd923bc8 100644 --- a/src/components/speech-content/speech-item.tsx +++ b/src/components/speech-content/speech-item.tsx @@ -124,6 +124,11 @@ const SpeechItem: React.FC = (props) => { debounceSeek(value); }; + const handlOnChangeComplete = useCallback((value: number) => { + ref.current?.seekTo(value / duration); + setCurrentTime(value); + }, []); + const onDownload = useCallback(() => { const url = props.audioUrl || ''; const filename = `audio-${dayjs().format('YYYYMMDDHHmmss')}.${props.format}`; diff --git a/src/constants/external-links.ts b/src/constants/external-links.ts index a8d9494f..c0a337c5 100644 --- a/src/constants/external-links.ts +++ b/src/constants/external-links.ts @@ -1,7 +1,13 @@ -export default { +const externalLinks = { documentation: 'https://docs.gpustack.ai/', github: 'https://github.com/gpustack/gpustack', discord: 'https://discord.gg/VXYJzuaqwD', site: 'https://gpustack.ai/', release: 'https://github.com/gpustack/gpustack/releases' }; + +export default externalLinks; + +export const externalRefer = { + audioPermission: `${externalLinks.documentation}latest/user-guide/playground/#audio-playground` +}; diff --git a/src/locales/en-US/playground.ts b/src/locales/en-US/playground.ts index e1e510be..a78ac172 100644 --- a/src/locales/en-US/playground.ts +++ b/src/locales/en-US/playground.ts @@ -84,6 +84,7 @@ export default { 'Upload an audio file or start recording', 'playground.audio.enablemic': "Enable microphone access in your browser's settings.", + 'playground.audio.enablemic.doc': 'Refer to', 'playground.audio.startrecord': 'Start Recording', 'playground.audio.stoprecord': 'Stop Recording', 'playground.audio.generating.tips': 'Generated text will appear here.', diff --git a/src/locales/zh-CN/playground.ts b/src/locales/zh-CN/playground.ts index eb555d6e..d91f6181 100644 --- a/src/locales/zh-CN/playground.ts +++ b/src/locales/zh-CN/playground.ts @@ -82,6 +82,7 @@ export default { 'playground.audio.texttospeech.tips': '生成的语音将出现在这里', 'playground.audio.speechtotext.tips': '上传音频文件或开始录音', 'playground.audio.enablemic': '请允许浏览器访问麦克风,以便开始录音', + 'playground.audio.enablemic.doc': '参考文档', 'playground.audio.startrecord': '开始录音', 'playground.audio.stoprecord': '停止录音', 'playground.audio.generating.tips': '生成的文本将出现在这里', diff --git a/src/pages/playground/components/audio-input.tsx b/src/pages/playground/components/audio-input.tsx index e090d005..cafe75b4 100644 --- a/src/pages/playground/components/audio-input.tsx +++ b/src/pages/playground/components/audio-input.tsx @@ -1,3 +1,4 @@ +import { externalRefer } from '@/constants/external-links'; import { AudioOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Button, Space, Tooltip } from 'antd'; @@ -215,7 +216,25 @@ const AudioInput: React.FC = (props) => { const renderRecordButtonTips = useMemo(() => { if (!audioPermission) { - return intl.formatMessage({ id: 'playground.audio.enablemic' }); + return ( + + + {intl.formatMessage({ id: 'playground.audio.enablemic' })} + + + + ); } return isRecording ? intl.formatMessage({ id: 'playground.audio.stoprecord' }) diff --git a/src/pages/playground/components/ground-stt.tsx b/src/pages/playground/components/ground-stt.tsx index 84152381..b964f0c5 100644 --- a/src/pages/playground/components/ground-stt.tsx +++ b/src/pages/playground/components/ground-stt.tsx @@ -120,7 +120,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { } ); - if (result?.status_code !== 200) { + if (result?.status_code && result?.status_code !== 200) { setTokenResult({ error: true, errorMessage: @@ -211,6 +211,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { setIsRecording(val); setAudioData(null); setTokenResult(null); + setMessageList([]); console.log('data===', val); }, []); diff --git a/src/pages/playground/components/ground-tts.tsx b/src/pages/playground/components/ground-tts.tsx index 9a949490..f434f2f7 100644 --- a/src/pages/playground/components/ground-tts.tsx +++ b/src/pages/playground/components/ground-tts.tsx @@ -52,17 +52,7 @@ const GroundLeft: React.FC = forwardRef((props, ref) => { autoplay: boolean; audioUrl: string; }[] - >([ - { - input: '', - voice: '', - format: '', - speed: 0, - uid: 0, - autoplay: false, - audioUrl: '' - } - ]); + >([]); const locale = getLocale(); const intl = useIntl(); const [searchParams] = useSearchParams();