Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(style): stt loading #213

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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