chore: audio file .m4a support

This commit is contained in:
jialin
2025-01-09 14:11:26 +08:00
parent fb9d2d99d4
commit 08f9029bf8
7 changed files with 20 additions and 31 deletions
+5 -5
View File
@@ -14,11 +14,11 @@
&::before { &::before {
content: ''; content: '';
position: absolute; position: absolute;
top: 30px; top: 0;
bottom: 30px; bottom: 0;
right: 0; right: -18px;
width: 100px; width: 80px;
height: 60px; height: 185px;
&:hover { &:hover {
.pagination { .pagination {
@@ -45,6 +45,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const loadMoreDone = useRef(false); const loadMoreDone = useRef(false);
const pageRef = useRef<any>(page); const pageRef = useRef<any>(page);
const totalPageRef = useRef<any>(totalPage); const totalPageRef = useRef<any>(totalPage);
const isLoadingMoreRef = useRef(false);
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
abort() { abort() {
@@ -79,6 +80,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const debounceLoading = _.debounce(() => { const debounceLoading = _.debounce(() => {
setLoading(false); setLoading(false);
isLoadingMoreRef.current = false;
}, 200); }, 200);
const isClean = useCallback((input: string) => { const isClean = useCallback((input: string) => {
@@ -91,8 +93,9 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const getLastPage = (data: string) => { const getLastPage = (data: string) => {
const list = _.split(data.trim(), '\n'); const list = _.split(data.trim(), '\n');
let result = ''; let result = '';
console.log('getlastPage===', list.length, enableScorllLoad, pageSize); if (isLoadingMoreRef.current) {
setLoading(true); setLoading(true);
}
if (!enableScorllLoad) { if (!enableScorllLoad) {
result = list.join('\n'); result = list.join('\n');
} else if (list.length <= pageSize) { } else if (list.length <= pageSize) {
@@ -142,7 +145,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const start = (newPage - 1) * pageSize; const start = (newPage - 1) * pageSize;
const end = newPage * pageSize; const end = newPage * pageSize;
const prePage = list.slice(start, end).join('\n'); const prePage = list.slice(start, end).join('\n');
console.log('prePage===', newPage);
setPage(() => newPage); setPage(() => newPage);
setScrollPos(['bottom', newPage]); setScrollPos(['bottom', newPage]);
pageRef.current = newPage; pageRef.current = newPage;
@@ -160,7 +163,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
const start = (newPage - 1) * pageSize; const start = (newPage - 1) * pageSize;
const end = newPage * pageSize; const end = newPage * pageSize;
const nextPage = list.slice(start, end).join('\n'); const nextPage = list.slice(start, end).join('\n');
console.log('nextPage===', newPage);
setPage(() => newPage); setPage(() => newPage);
setScrollPos(['top', newPage]); setScrollPos(['top', newPage]);
pageRef.current = newPage; pageRef.current = newPage;
@@ -241,6 +244,7 @@ const LogsViewer: React.FC<LogsViewerProps> = forwardRef((props, ref) => {
tail.current = undefined; tail.current = undefined;
createChunkConnection(); createChunkConnection();
loadMoreDone.current = true; loadMoreDone.current = true;
isLoadingMoreRef.current = true;
} else if (isTop && page <= totalPage && page > 1) { } else if (isTop && page <= totalPage && page > 1) {
// getPrePage(); // getPrePage();
} else if (isBottom && page < totalPage) { } else if (isBottom && page < totalPage) {
+1 -1
View File
@@ -24,7 +24,7 @@ const UploadAudio: React.FC<UploadAudioProps> = (props) => {
); );
return ( return (
<Tooltip <Tooltip
overlayInnerStyle={{ maxWidth: 265, width: 'max-content' }} overlayInnerStyle={{ maxWidth: 290, width: 'max-content' }}
title={intl.formatMessage( title={intl.formatMessage(
{ id: 'playground.audio.uploadfile.tips' }, { id: 'playground.audio.uploadfile.tips' },
{ formats: props.accept } { formats: props.accept }
-19
View File
@@ -1,6 +1,5 @@
import PageTools from '@/components/page-tools'; import PageTools from '@/components/page-tools';
import { PageAction } from '@/config'; import { PageAction } from '@/config';
import breakpoints from '@/config/breakpoints';
import { SyncOutlined } from '@ant-design/icons'; import { SyncOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-components';
import { useIntl, useNavigate } from '@umijs/max'; import { useIntl, useNavigate } from '@umijs/max';
@@ -104,24 +103,6 @@ const Catalog: React.FC = () => {
setActiveId(-1); setActiveId(-1);
}; };
const handleResize = useCallback(
_.throttle((size: { width: number; height: number }) => {
const { width } = size;
if (width < breakpoints.xs) {
setSpan(24);
} else if (width < breakpoints.sm) {
setSpan(24);
} else if (width < breakpoints.md) {
setSpan(12);
} else if (width < breakpoints.lg) {
setSpan(12);
} else {
setSpan(8);
}
}, 100),
[]
);
const handleOnDeploy = useCallback((item: CatalogItemType) => { const handleOnDeploy = useCallback((item: CatalogItemType) => {
setActiveId(item.id); setActiveId(item.id);
setOpenDeployModal({ setOpenDeployModal({
@@ -1,5 +1,5 @@
import breakpoints from '@/config/breakpoints'; import breakpoints from '@/config/breakpoints';
import { Col, Row, Spin } from 'antd'; import { Col, FloatButton, Row, Spin } from 'antd';
import ResizeObserver from 'rc-resize-observer'; import ResizeObserver from 'rc-resize-observer';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { CatalogItem as CatalogItemType } from '../config/types'; import { CatalogItem as CatalogItemType } from '../config/types';
@@ -80,6 +80,7 @@ const CatalogList: React.FC<CatalogListProps> = (props) => {
)} )}
</div> </div>
</ResizeObserver> </ResizeObserver>
<FloatButton.BackTop visibilityHeight={1000} />
</div> </div>
); );
}; };
@@ -25,6 +25,7 @@ import {
useState useState
} from 'react'; } from 'react';
import { speechToText } from '../apis'; import { speechToText } from '../apis';
import { SpeechToTextFormat } from '../config';
import { RealtimeParamsConfig as paramsConfig } from '../config/params-config'; import { RealtimeParamsConfig as paramsConfig } from '../config/params-config';
import '../style/ground-left.less'; import '../style/ground-left.less';
import '../style/speech-to-text.less'; import '../style/speech-to-text.less';
@@ -306,7 +307,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
{!isRecording && ( {!isRecording && (
<UploadAudio <UploadAudio
type="default" type="default"
accept=".mp3,.mp4,.wav" accept={SpeechToTextFormat.join(',')}
onChange={handleUploadChange} onChange={handleUploadChange}
></UploadAudio> ></UploadAudio>
)} )}
+2
View File
@@ -137,6 +137,8 @@ export const OpenAIViewCode = {
} }
}; };
export const SpeechToTextFormat = ['.mp3', '.mp4', '.wav', '.m4a'];
export const promptList = [ export const promptList = [
'a lovely cat.', 'a lovely cat.',
"Digital art, portrait of an anthropomorphic roaring Tiger warrior with full armor, close up in the middle of a battle, behind him there is a banner with the text 'Open Source'.", "Digital art, portrait of an anthropomorphic roaring Tiger warrior with full armor, close up in the middle of a battle, behind him there is a banner with the text 'Open Source'.",