package main import ( "context" "time" "go.mau.fi/whatsmeow/proto/waE2E" ) // whatsappVoiceDownloadTimeout bounds one voice-note media download. const whatsappVoiceDownloadTimeout = 2 * time.Minute // whatsappVoice stores and transcribes accepted voice notes before their batch // is acknowledged. Failure markers reveal no URLs, keys, or process output. func whatsappVoice(ctx context.Context, client WhatsAppClient, store *VoiceStore, transcriber *VoiceTranscriber, audio *waE2E.AudioMessage) string { if audio.GetFileLength() > voiceMaxBytes || client == nil { return "(voice not downloaded)" } downloadCtx, cancel := context.WithTimeout(ctx, whatsappVoiceDownloadTimeout) defer cancel() data, err := client.Download(downloadCtx, audio) if err != nil { return "(voice not downloaded)" } return transcriber.Text(ctx, store, data) }