Skip to content

Commit

Permalink
fix(style): stt loading
Browse files Browse the repository at this point in the history
  • Loading branch information
hibig committed Nov 29, 2024
1 parent 1ac3768 commit 412c6da
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/speech-content/hooks/use-wavesurfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface Options {
autoplay?: boolean;
audioRate?: number;
onReady?: () => void;
onClick: (value: any) => void;
onClick: (value: number) => void;
}
const useWavesurfer = (options: Options) => {
const wavesurfer = useRef<WaveSurfer | null>(null);
Expand Down
6 changes: 6 additions & 0 deletions src/pages/playground/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ export const textToSpeech = async (params: any, options?: any) => {
}

const audioBlob = await res.blob();
if (audioBlob?.type?.indexOf('audio') === -1) {
return {
url: '',
type: ''
};
}
const audioUrl = audioBlob.size > 0 ? URL.createObjectURL(audioBlob) : '';
return {
url: audioUrl,
Expand Down
28 changes: 16 additions & 12 deletions src/pages/playground/components/ground-stt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setLoading(true);
setMessageId();
setTokenResult(null);
setMessageList([]);

controllerRef.current?.abort?.();
controllerRef.current = new AbortController();
Expand Down Expand Up @@ -137,7 +138,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setTokenResult({
error: true,
errorMessage:
res?.error?.message || res?.data?.error || res?.error?.detail || ''
res?.error?.message || res?.data?.error || res?.detail || ''
});
}
} finally {
Expand Down Expand Up @@ -292,7 +293,10 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
</div>

{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 }}>
<AudioPlayer
url={audioData.url}
Expand All @@ -302,7 +306,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
</div>
<div
style={{
padding: '16px 32px',
padding: '16px',
textAlign: 'right',
position: 'absolute',
right: 0,
Expand Down Expand Up @@ -371,8 +375,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
padding: '8px 14px',
lineHeight: '20px',
display: 'flex',
justifyContent: 'center',
textAlign: 'center'
justifyContent: 'center'
}}
>
{messageList.length ? (
Expand All @@ -394,14 +397,15 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
></AlertInfo>
</div>
)}
{loading && (
<Spin size="small">
<div style={{ height: '46px' }}></div>
</Spin>
)}
</>
</div>
<div></div>
{loading && (
<div style={{ width: '100%', flex: 1 }}>
<Spin size="small">
<div style={{ height: '46px' }}></div>
</Spin>
</div>
)}
</div>
</div>
</div>
Expand All @@ -418,7 +422,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
paramsConfig={paramsConfig}
initialValues={initialValues}
params={parameters}
selectedModel={selectModel}
selectedModel={selectModel as string}
modelList={modelList}
/>
</div>
Expand Down
9 changes: 3 additions & 6 deletions src/pages/playground/components/ground-tts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setTokenResult({
error: true,
errorMessage:
res?.data?.error?.message ||
res?.data?.error ||
res?.error?.detail ||
''
res?.data?.error?.message || res?.data?.error || res?.detail || ''
});
setMessageList([]);
return;
Expand All @@ -154,7 +151,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setTokenResult({
error: true,
errorMessage:
res?.error?.message || res?.data?.error || res?.error?.detail || ''
res?.error?.message || res?.data?.error || res?.detail || ''
});
}
} finally {
Expand Down Expand Up @@ -384,7 +381,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
setParams={setParams}
initialValues={initialValues}
params={parameters}
selectedModel={selectModel}
selectedModel={selectModel as string}
modelList={modelList}
extra={[renderExtra, renderVoiceError]}
/>
Expand Down

0 comments on commit 412c6da

Please sign in to comment.