fix: add comprehensive logging for voice clone debugging
- Backend: change logger.info to logger.warning for production logs - Frontend: add console logs in brandAssets.ts createVoiceClone - Frontend: add token auth and audio error logs in VoiceAvatarPlaceholder - Log token fetching, authenticated URL, audio duration
This commit is contained in:
@@ -195,6 +195,8 @@ export const createVoiceClone = async (
|
||||
params: VoiceCloneParams
|
||||
): Promise<VoiceCloneResponse> => {
|
||||
try {
|
||||
console.log('[VoiceClone] Creating voice clone with engine:', params.engine);
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', params.audioFile);
|
||||
formData.append('engine', params.engine);
|
||||
@@ -214,14 +216,16 @@ export const createVoiceClone = async (
|
||||
// We might want to remove this if backend doesn't need it
|
||||
formData.append('voice_name', 'My Voice Clone');
|
||||
|
||||
console.log('[VoiceClone] Sending request to /onboarding/assets/create-voice-clone');
|
||||
const response = await apiClient.post('/onboarding/assets/create-voice-clone', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
console.log('[VoiceClone] Response received:', response.data);
|
||||
return response.data;
|
||||
} catch (error: any) {
|
||||
console.error('Voice cloning error:', error);
|
||||
console.error('[VoiceClone] Error creating voice clone:', error.response?.data || error.message);
|
||||
return {
|
||||
success: false,
|
||||
error: error.response?.data?.detail || 'Failed to create voice clone'
|
||||
|
||||
@@ -100,7 +100,9 @@ export const VoiceAvatarPlaceholder: React.FC<{ domainName?: string; onVoiceSet?
|
||||
const [authenticatedAudioUrl, setAuthenticatedAudioUrl] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
console.log('[VoiceClone] resultAudioUrl changed:', resultAudioUrl);
|
||||
if (!resultAudioUrl || !resultAudioUrl.includes('/api/')) {
|
||||
console.log('[VoiceClone] Using resultAudioUrl directly (no API auth needed)');
|
||||
setAuthenticatedAudioUrl(resultAudioUrl);
|
||||
return;
|
||||
}
|
||||
@@ -110,14 +112,22 @@ export const VoiceAvatarPlaceholder: React.FC<{ domainName?: string; onVoiceSet?
|
||||
const tokenGetter = getAuthTokenGetter();
|
||||
if (tokenGetter) {
|
||||
const token = await tokenGetter();
|
||||
console.log('[VoiceClone] Got token:', token ? 'yes' : 'no');
|
||||
if (token && !cancelled) {
|
||||
const sep = resultAudioUrl.includes('?') ? '&' : '?';
|
||||
setAuthenticatedAudioUrl(`${resultAudioUrl}${sep}token=${encodeURIComponent(token)}`);
|
||||
const authUrl = `${resultAudioUrl}${sep}token=${encodeURIComponent(token)}`;
|
||||
console.log('[VoiceClone] Setting authenticatedAudioUrl:', authUrl);
|
||||
setAuthenticatedAudioUrl(authUrl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch { /* fallback to unauthenticated */ }
|
||||
if (!cancelled) setAuthenticatedAudioUrl(resultAudioUrl);
|
||||
} catch (e) {
|
||||
console.warn('[VoiceClone] Token fetch error:', e);
|
||||
}
|
||||
if (!cancelled) {
|
||||
console.log('[VoiceClone] Falling back to unauthenticated URL');
|
||||
setAuthenticatedAudioUrl(resultAudioUrl);
|
||||
}
|
||||
})();
|
||||
return () => { cancelled = true; };
|
||||
}, [resultAudioUrl]);
|
||||
@@ -1123,8 +1133,13 @@ export const VoiceAvatarPlaceholder: React.FC<{ domainName?: string; onVoiceSet?
|
||||
src={authenticatedAudioUrl || undefined}
|
||||
preload="auto"
|
||||
style={{ width: '100%', height: '28px' }}
|
||||
onLoadedMetadata={(e) => {
|
||||
console.log('[VoiceClone] Audio duration loaded:', (e.target as HTMLAudioElement).duration);
|
||||
}}
|
||||
onError={(e) => {
|
||||
console.error('[VoiceClone] Generated audio playback error:', e);
|
||||
const audioEl = e.target as HTMLAudioElement;
|
||||
const errorMsg = audioEl?.error ? `code=${audioEl.error.code}, message=${audioEl.error.message}` : 'unknown';
|
||||
console.error('[VoiceClone] Generated audio playback error:', errorMsg, 'URL:', authenticatedAudioUrl);
|
||||
}}
|
||||
/>
|
||||
<Stack direction="row" spacing={1} sx={{ mt: 1 }}>
|
||||
|
||||
Reference in New Issue
Block a user