Update app.py
Browse files106 unmodified lines10710810911011111211311411533 unmodified lines1491501511521531545 unmodified lines1601611621631641651661671681691701 unmodified line172173174175176177106 unmodified linesif len(transcript) < 10:raise ValueError("Transcription too short, possibly failed")return transcriptexcept Exception as e:error_message = f"An error occurred: {str(e)}"logger.error(error_message)return error_message33 unmodified linesdef transcribe():try:transcript = transcribe_video(url)return transcriptexcept Exception as e:logger.exception("Error in transcription:")5 unmodified linesthread.join(timeout=600) # 10 minutes timeoutif thread.is_alive():return "Transcription timed out after 10 minutes", {'display': 'none'}transcript = getattr(thread, 'result', "Transcription failed")if transcript and not transcript.startswith("An error occurred"):return dbc.Card([dbc.CardBody([html.H5("Transcription Result"),1 unmodified line])]), {'display': 'block'}else:return transcript, {'display': 'none'}@app.callback(106 unmodified lines10710810911011111211311411511611711833 unmodified lines1521531541551561571585 unmodified lines1641651661671681691701711721731741751761771 unmodified line179180181182183184185106 unmodified linesif len(transcript) < 10:raise ValueError("Transcription too short, possibly failed")logger.info(f"Transcription successful. Length: {len(transcript)} characters")logger.info(f"First 100 characters of transcript: {transcript[:100]}...")return transcriptexcept Exception as e:error_message = f"An error occurred in transcribe_video: {str(e)}"logger.error(error_message)return error_message33 unmodified linesdef transcribe():try:transcript = transcribe_video(url)logger.info(f"Transcription completed. Result length: {len(transcript)} characters")return transcriptexcept Exception as e:logger.exception("Error in transcription:")5 unmodified linesthread.join(timeout=600) # 10 minutes timeoutif thread.is_alive():logger.warning("Transcription timed out after 10 minutes")return "Transcription timed out after 10 minutes", {'display': 'none'}transcript = getattr(thread, 'result', "Transcription failed")logger.info(f"Final transcript length: {len(transcript)} characters")if transcript and not transcript.startswith("An error occurred"):logger.info("Transcription successful, returning result")return dbc.Card([dbc.CardBody([html.H5("Transcription Result"),1 unmodified line])]), {'display': 'block'}else:logger.error(f"Transcription failed: {transcript}")return transcript, {'display': 'none'}@app.callback(
app.py+9-1