Spaces:
Sleeping
Sleeping
Commit ·
ee686b8
1
Parent(s): f567855
test
Browse files
README.md
CHANGED
|
@@ -7,6 +7,9 @@ sdk: gradio
|
|
| 7 |
sdk_version: 6.13.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
|
|
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 7 |
sdk_version: 6.13.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
hf_oauth: true
|
| 11 |
+
hf_oauth_scopes:
|
| 12 |
+
- inference-api
|
| 13 |
---
|
| 14 |
|
| 15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -2,21 +2,25 @@ import gradio as gr
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
|
| 5 |
-
def transcribe_audio(audio_file_path):
|
| 6 |
-
"""Transcribe audio using
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
transcript = client.automatic_speech_recognition(
|
| 11 |
audio=audio_file_path,
|
| 12 |
model="openai/whisper-large-v3"
|
| 13 |
)
|
| 14 |
-
|
| 15 |
return transcript.text
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
prompt = f"""
|
| 22 |
Analyze this meeting transcript and provide:
|
|
@@ -37,31 +41,47 @@ def generate_summary(transcript):
|
|
| 37 |
messages=[{"role": "user", "content": prompt}],
|
| 38 |
max_tokens=1000
|
| 39 |
)
|
| 40 |
-
|
| 41 |
return response.choices[0].message.content
|
| 42 |
|
| 43 |
|
| 44 |
-
def process_meeting_audio(audio_file):
|
| 45 |
-
"""Process uploaded audio file and return transcript + summary"""
|
|
|
|
|
|
|
|
|
|
| 46 |
if audio_file is None:
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
# We'll implement the AI logic next
|
| 50 |
-
return "Transcript will appear here...", "Summary will appear here..."
|
| 51 |
-
|
| 52 |
-
# Create the Gradio interface
|
| 53 |
-
app = gr.Interface(
|
| 54 |
-
fn=process_meeting_audio,
|
| 55 |
-
inputs=gr.Audio(label="Upload Meeting Audio", type="filepath"),
|
| 56 |
-
outputs=[
|
| 57 |
-
gr.Textbox(label="Transcript", lines=10),
|
| 58 |
-
gr.Textbox(label="Summary & Action Items", lines=8)
|
| 59 |
-
],
|
| 60 |
-
title="🎤 AI Meeting Notes",
|
| 61 |
-
description="Upload an audio file to get an instant transcript and summary with action items."
|
| 62 |
-
)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
|
|
|
|
|
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
|
| 5 |
+
def transcribe_audio(audio_file_path: str, oauth_token: gr.OAuthToken | None) -> str:
|
| 6 |
+
"""Transcribe audio using Inference Providers, billed to the user."""
|
| 7 |
+
if oauth_token is None:
|
| 8 |
+
raise gr.Error("Please sign in with Hugging Face first.")
|
| 9 |
|
| 10 |
+
client = InferenceClient(provider="auto", token=oauth_token.token)
|
| 11 |
transcript = client.automatic_speech_recognition(
|
| 12 |
audio=audio_file_path,
|
| 13 |
model="openai/whisper-large-v3"
|
| 14 |
)
|
|
|
|
| 15 |
return transcript.text
|
| 16 |
|
| 17 |
+
|
| 18 |
+
def generate_summary(transcript: str, oauth_token: gr.OAuthToken | None) -> str:
|
| 19 |
+
"""Generate summary using Inference Providers, billed to the user."""
|
| 20 |
+
if oauth_token is None:
|
| 21 |
+
raise gr.Error("Please sign in with Hugging Face first.")
|
| 22 |
+
|
| 23 |
+
client = InferenceClient(provider="auto", token=oauth_token.token)
|
| 24 |
|
| 25 |
prompt = f"""
|
| 26 |
Analyze this meeting transcript and provide:
|
|
|
|
| 41 |
messages=[{"role": "user", "content": prompt}],
|
| 42 |
max_tokens=1000
|
| 43 |
)
|
|
|
|
| 44 |
return response.choices[0].message.content
|
| 45 |
|
| 46 |
|
| 47 |
+
def process_meeting_audio(audio_file, oauth_token: gr.OAuthToken | None):
|
| 48 |
+
"""Process uploaded audio file and return transcript + summary."""
|
| 49 |
+
if oauth_token is None:
|
| 50 |
+
raise gr.Error("Please sign in with Hugging Face first.")
|
| 51 |
+
|
| 52 |
if audio_file is None:
|
| 53 |
+
raise gr.Error("Please upload an audio file.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
+
transcript = transcribe_audio(audio_file, oauth_token)
|
| 56 |
+
summary = generate_summary(transcript, oauth_token)
|
| 57 |
+
return transcript, summary
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
with gr.Blocks() as app:
|
| 61 |
+
gr.Markdown("# 🎤 AI Meeting Notes")
|
| 62 |
+
gr.Markdown(
|
| 63 |
+
"Sign in with your Hugging Face account, then upload a meeting recording "
|
| 64 |
+
"to get an instant transcript and summary. Inference is billed to your account."
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
gr.LoginButton()
|
| 68 |
+
|
| 69 |
+
with gr.Row():
|
| 70 |
+
audio_input = gr.Audio(label="Upload Meeting Audio", type="filepath")
|
| 71 |
|
| 72 |
+
with gr.Row():
|
| 73 |
+
submit_btn = gr.Button("Process", variant="primary")
|
| 74 |
|
| 75 |
+
with gr.Row():
|
| 76 |
+
transcript_output = gr.Textbox(label="Transcript", lines=10)
|
| 77 |
+
summary_output = gr.Textbox(label="Summary & Action Items", lines=10)
|
| 78 |
+
|
| 79 |
+
submit_btn.click(
|
| 80 |
+
fn=process_meeting_audio,
|
| 81 |
+
inputs=[audio_input],
|
| 82 |
+
outputs=[transcript_output, summary_output],
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
if __name__ == "__main__":
|
| 87 |
+
app.launch()
|