fix: speech size 0, do not create url

This commit is contained in:
jialin
2024-11-29 21:09:03 +08:00
parent e622636686
commit 1ac3768468
8 changed files with 77 additions and 18 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ export const textToSpeech = async (params: any, options?: any) => {
}
const audioBlob = await res.blob();
const audioUrl = URL.createObjectURL(audioBlob);
const audioUrl = audioBlob.size > 0 ? URL.createObjectURL(audioBlob) : '';
return {
url: audioUrl,
type: audioBlob.type
+10 -2
View File
@@ -119,7 +119,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
errorMessage:
result?.data?.error?.message ||
result?.data?.message ||
result.error.detail ||
result?.detail ||
''
});
return;
@@ -130,8 +130,16 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
uid: messageId.current
}
]);
} catch (error) {
} catch (error: any) {
console.log('error:', error);
const res = error?.response?.data;
if (res.error) {
setTokenResult({
error: true,
errorMessage:
res?.error?.message || res?.data?.error || res?.error?.detail || ''
});
}
} finally {
setLoading(false);
setIsRecording(false);
+10 -3
View File
@@ -130,7 +130,7 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
errorMessage:
res?.data?.error?.message ||
res?.data?.error ||
res.error?.detail ||
res?.error?.detail ||
''
});
setMessageList([]);
@@ -148,8 +148,15 @@ const GroundLeft: React.FC<MessageProps> = forwardRef((props, ref) => {
audioUrl: res.url
}
]);
} catch (error) {
console.log('error:', error);
} catch (error: any) {
const res = error?.response?.data;
if (res.error) {
setTokenResult({
error: true,
errorMessage:
res?.error?.message || res?.data?.error || res?.error?.detail || ''
});
}
} finally {
setLoading(false);
}