fix(style): stt loading

This commit is contained in:
jialin
2024-11-29 22:10:52 +08:00
parent 1ac3768468
commit 412c6dadca
4 changed files with 26 additions and 19 deletions
@@ -12,7 +12,7 @@ interface Options {
autoplay?: boolean; autoplay?: boolean;
audioRate?: number; audioRate?: number;
onReady?: () => void; onReady?: () => void;
onClick: (value: any) => void; onClick: (value: number) => void;
} }
const useWavesurfer = (options: Options) => { const useWavesurfer = (options: Options) => {
const wavesurfer = useRef<WaveSurfer | null>(null); const wavesurfer = useRef<WaveSurfer | null>(null);
+6
View File
@@ -98,6 +98,12 @@ export const textToSpeech = async (params: any, options?: any) => {
} }
const audioBlob = await res.blob(); const audioBlob = await res.blob();
if (audioBlob?.type?.indexOf('audio') === -1) {
return {
url: '',
type: ''
};
}
const audioUrl = audioBlob.size > 0 ? URL.createObjectURL(audioBlob) : ''; const audioUrl = audioBlob.size > 0 ? URL.createObjectURL(audioBlob) : '';
return { return {
url: audioUrl, url: audioUrl,
+16 -12
View File
@@ -99,6 +99,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setLoading(true); setLoading(true);
setMessageId(); setMessageId();
setTokenResult(null); setTokenResult(null);
setMessageList([]);
controllerRef.current?.abort?.(); controllerRef.current?.abort?.();
controllerRef.current = new AbortController(); controllerRef.current = new AbortController();
@@ -137,7 +138,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setTokenResult({ setTokenResult({
error: true, error: true,
errorMessage: errorMessage:
res?.error?.message || res?.data?.error || res?.error?.detail || '' res?.error?.message || res?.data?.error || res?.detail || ''
}); });
} }
} finally { } finally {
@@ -292,7 +293,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
</div> </div>
{audioData ? ( {audioData ? (
<div className="flex-between flex-center justify-center relative"> <div
className="flex-between flex-center justify-center relative"
style={{ paddingInline: 80 }}
>
<div style={{ width: 600 }}> <div style={{ width: 600 }}>
<AudioPlayer <AudioPlayer
url={audioData.url} url={audioData.url}
@@ -302,7 +306,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
</div> </div>
<div <div
style={{ style={{
padding: '16px 32px', padding: '16px',
textAlign: 'right', textAlign: 'right',
position: 'absolute', position: 'absolute',
right: 0, right: 0,
@@ -371,8 +375,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
padding: '8px 14px', padding: '8px 14px',
lineHeight: '20px', lineHeight: '20px',
display: 'flex', display: 'flex',
justifyContent: 'center', justifyContent: 'center'
textAlign: 'center'
}} }}
> >
{messageList.length ? ( {messageList.length ? (
@@ -394,14 +397,15 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
></AlertInfo> ></AlertInfo>
</div> </div>
)} )}
{loading && (
<Spin size="small">
<div style={{ height: '46px' }}></div>
</Spin>
)}
</> </>
</div> </div>
<div></div> {loading && (
<div style={{ width: '100%', flex: 1 }}>
<Spin size="small">
<div style={{ height: '46px' }}></div>
</Spin>
</div>
)}
</div> </div>
</div> </div>
</div> </div>
@@ -418,7 +422,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
paramsConfig={paramsConfig} paramsConfig={paramsConfig}
initialValues={initialValues} initialValues={initialValues}
params={parameters} params={parameters}
selectedModel={selectModel} selectedModel={selectModel as string}
modelList={modelList} modelList={modelList}
/> />
</div> </div>
@@ -128,10 +128,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setTokenResult({ setTokenResult({
error: true, error: true,
errorMessage: errorMessage:
res?.data?.error?.message || res?.data?.error?.message || res?.data?.error || res?.detail || ''
res?.data?.error ||
res?.error?.detail ||
''
}); });
setMessageList([]); setMessageList([]);
return; return;
@@ -154,7 +151,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setTokenResult({ setTokenResult({
error: true, error: true,
errorMessage: errorMessage:
res?.error?.message || res?.data?.error || res?.error?.detail || '' res?.error?.message || res?.data?.error || res?.detail || ''
}); });
} }
} finally { } finally {
@@ -384,7 +381,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setParams={setParams} setParams={setParams}
initialValues={initialValues} initialValues={initialValues}
params={parameters} params={parameters}
selectedModel={selectModel} selectedModel={selectModel as string}
modelList={modelList} modelList={modelList}
extra={[renderExtra, renderVoiceError]} extra={[renderExtra, renderVoiceError]}
/> />