import gradio as gr import os from cs_ai_kt_transcribe_share.kt_transcript import KnowledgeTranscriber def process_inputs(api_key, drive_folder_link): os.environ['OPENAI_API_KEY'] = api_key # Set the API_KEY environment variable try: # Assuming drive_link is the folder_path and transcribe_flag is derived or fixed folder_path = drive_folder_link # Example adjustment, actual implementation may vary transcribe_flag = True # Example, adjust based on actual use case kt = KnowledgeTranscriber(os.environ['OPENAI_API_KEY']) # Create an instance of KnowledgeTranscriber kt.process_folder('scripts/ktTranscript/cs_ai_kt_transcribe_share/Input-Folder', True, drive_folder_link) # Call the method return "Success" except ValueError as e: kt.cleanup_input_folder('scripts/ktTranscript/cs_ai_kt_transcribe_share/Input-Folder') return str(e) # Return the exception message as the result except Exception as e: # Catch all other runtime errors if 'kt' in locals(): # Check if 'kt' was successfully created kt.cleanup_input_folder('scripts/ktTranscript/cs_ai_kt_transcribe_share/Input-Folder') return "Fail: " + str(e) # Return a generic fail result along with the exception message demo = gr.Interface( process_inputs, [ gr.Textbox( label="OpenAI Key", info="Enter your OpenAI API Key here e.g., sk-xxxxxxxxxxxxxx" ), gr.Textbox( label="Drive Folder Link", info="Enter your Drive Folder Link here (it must be public) e.g., https://drive.google.com/drive/folders/your-folder-id" ), ], gr.Textbox(label="Result"), description="""**Knowledge Transcriber Self-Service Guide** This script powers the Knowledge Transcriber application, providing an easy-to-use interface for users to transcribe video recordings stored in Google Drive. Follow these steps to use the application: 1. **OpenAI API Key**: Obtain an OpenAI API key, which is necessary for transcription services. 2. **Google Drive Folder**: Ensure your mp4 video recording is stored in a Google Drive folder that is publicly accessible. 3. **Enter Details**: In the below interface, input your OpenAI API key and the link to your Google Drive folder containing the video recording. 4. **Process Videos**: Submit the form, and the application will process the videos, generating transcripts and other outputs. 5. **Access Outputs**: Outputs will be stored in your Google Drive folder. Please ensure Google Drive folder has the necessary permissions.""", theme=gr.themes.Base() ) demo.launch() # Share your demo with just 1 extra parameter 🚀