import gradio as gr from huggingface_hub import InferenceClient def transcribe_audio(audio_file_path: str, oauth_token: gr.OAuthToken | None) -> str: """Transcribe audio using Inference Providers, billed to the user.""" if oauth_token is None: raise gr.Error("Please sign in with Hugging Face first.") client = InferenceClient(provider="auto", token=oauth_token.token) transcript = client.automatic_speech_recognition( audio=audio_file_path, model="openai/whisper-large-v3" ) return transcript.text def generate_summary(transcript: str, oauth_token: gr.OAuthToken | None) -> str: """Generate summary using Inference Providers, billed to the user.""" if oauth_token is None: raise gr.Error("Please sign in with Hugging Face first.") client = InferenceClient(provider="auto", token=oauth_token.token) prompt = f""" Analyze this meeting transcript and provide: 1. A concise summary of key points 2. Action items with responsible parties 3. Important decisions made Transcript: {transcript} Format with clear sections: ## Summary ## Action Items ## Decisions Made """ response = client.chat.completions.create( model="deepseek-ai/DeepSeek-R1-0528:fastest", messages=[{"role": "user", "content": prompt}], max_tokens=1000 ) return response.choices[0].message.content def process_meeting_audio(audio_file, oauth_token: gr.OAuthToken | None): """Process uploaded audio file and return transcript + summary.""" if oauth_token is None: raise gr.Error("Please sign in with Hugging Face first.") if audio_file is None: raise gr.Error("Please upload an audio file.") transcript = transcribe_audio(audio_file, oauth_token) summary = generate_summary(transcript, oauth_token) return transcript, summary with gr.Blocks() as app: gr.Markdown("# 🎤 AI Meeting Notes") gr.Markdown( "Sign in with your Hugging Face account, then upload a meeting recording " "to get an instant transcript and summary. Inference is billed to your account." ) gr.LoginButton() with gr.Row(): audio_input = gr.Audio(label="Upload Meeting Audio", type="filepath") with gr.Row(): submit_btn = gr.Button("Process", variant="primary") with gr.Row(): transcript_output = gr.Textbox(label="Transcript", lines=10) summary_output = gr.Textbox(label="Summary & Action Items", lines=10) submit_btn.click( fn=process_meeting_audio, inputs=[audio_input], outputs=[transcript_output, summary_output], ) if __name__ == "__main__": app.launch()