voices
Some checks failed
Deploy Admin Panel / Deploy Admin Panel (push) Has been cancelled
Deploy Mnemo Cards / Deploy Backend (push) Has been cancelled
Deploy Admin Panel / Admin Panel Verification (push) Has been cancelled
Deploy Mnemo Cards / Deploy Web App (push) Has been cancelled
Deploy Mnemo Cards / Final Verification (push) Has been cancelled

This commit is contained in:
Dmitry 2026-03-22 15:52:51 +03:00
parent c9eef03aff
commit aa67c02343
3 changed files with 9 additions and 21 deletions

View file

@ -23,7 +23,7 @@ export const voicesApi = {
addCardVoice: async ( addCardVoice: async (
cardId: string, cardId: string,
voiceUrl: string, voiceUrl: string,
language: string = 'es' language: string = 'en'
): Promise<{ success: boolean; voice: VoiceDto }> => { ): Promise<{ success: boolean; voice: VoiceDto }> => {
const response = await adminApiClient.post(`/api/v2/admin/cards/${cardId}/voices`, { const response = await adminApiClient.post(`/api/v2/admin/cards/${cardId}/voices`, {
voiceUrl, voiceUrl,

View file

@ -20,7 +20,7 @@ export function AudioUpload({
label, label,
value, value,
onChange, onChange,
language = 'es', language = 'en',
onLanguageChange, onLanguageChange,
accept = 'audio/*', accept = 'audio/*',
maxSizeMB = 20, // Updated to match backend limit maxSizeMB = 20, // Updated to match backend limit
@ -173,18 +173,9 @@ export function AudioUpload({
audioRef.current = null audioRef.current = null
} }
audio.onerror = (e: Event | string) => { audio.onerror = (e) => {
console.error('Audio playback error:', e) console.error('Audio playback error:', e)
let errorMessage = 'Failed to play audio. The file may be corrupted, in an unsupported format, or the URL may have expired.' alert('Failed to play audio. The file may be corrupted or in an unsupported format.')
if (e instanceof Event) {
const audioElement = e.target as HTMLAudioElement | null
if (audioElement?.error) {
errorMessage = `Failed to load audio: ${audioElement.error.message || 'Unknown error'}`
}
}
alert(errorMessage)
setIsPlaying(false) setIsPlaying(false)
audioRef.current = null audioRef.current = null
} }
@ -195,10 +186,7 @@ export function AudioUpload({
audio.play().catch((error) => { audio.play().catch((error) => {
console.error('Audio play error:', error) console.error('Audio play error:', error)
const errorMessage = error instanceof Error alert('Failed to play audio. Please check your browser audio settings.')
? error.message
: 'Failed to play audio'
alert(`Failed to play audio: ${errorMessage}. Please check your browser audio settings.`)
setIsPlaying(false) setIsPlaying(false)
audioRef.current = null audioRef.current = null
}) })

View file

@ -76,7 +76,7 @@ export default function CardsPage() {
image: undefined as string | undefined, image: undefined as string | undefined,
imageBack: undefined as string | undefined, imageBack: undefined as string | undefined,
voice: undefined as string | undefined, voice: undefined as string | undefined,
voiceLanguage: 'es', voiceLanguage: 'en',
}) })
const limit = 20 const limit = 20
@ -173,7 +173,7 @@ export default function CardsPage() {
image: undefined, image: undefined,
imageBack: undefined, imageBack: undefined,
voice: undefined, voice: undefined,
voiceLanguage: 'es', voiceLanguage: 'en',
}) })
setIsDialogOpen(true) setIsDialogOpen(true)
} }
@ -191,7 +191,7 @@ export default function CardsPage() {
image: card.image, image: card.image,
imageBack: card.imageBack, imageBack: card.imageBack,
voice: undefined, voice: undefined,
voiceLanguage: 'es', voiceLanguage: 'en',
}) })
setIsDialogOpen(true) setIsDialogOpen(true)
} }
@ -230,7 +230,7 @@ export default function CardsPage() {
const voice = const voice =
formData.voice && formData.voice.trim() formData.voice && formData.voice.trim()
? { voiceUrl: formData.voice, language: formData.voiceLanguage || 'es' } ? { voiceUrl: formData.voice, language: formData.voiceLanguage || 'en' }
: undefined : undefined
if (isUpdate) { if (isUpdate) {