fix: speech size 0, do not create url
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user