Enrique Cardoza
commited on
Commit
·
5c2e2a4
1
Parent(s):
4d3ad0e
add request headers as param
Browse files
app.py
CHANGED
@@ -114,7 +114,7 @@ def transcribe_audio(audio_file, api_key):
|
|
114 |
except Exception as e:
|
115 |
return f"Error: {str(e)}"
|
116 |
|
117 |
-
def transcribe_audio_from_url(audio_url, api_key):
|
118 |
"""Transcribe audio/video files from a URL into text using Groq's Whisper model.
|
119 |
|
120 |
This tool converts spoken content from audio and video files into written text.
|
@@ -135,7 +135,14 @@ def transcribe_audio_from_url(audio_url, api_key):
|
|
135 |
"""
|
136 |
try:
|
137 |
# First check for environment variable, then use provided API key
|
138 |
-
actual_api_key = os.environ.get("GROQ_API_KEY"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
# Validate API key
|
141 |
if not actual_api_key:
|
@@ -307,4 +314,4 @@ with gr.Blocks(title="Audio/Video Transcription with Groq", theme=gr.themes.Soft
|
|
307 |
""")
|
308 |
|
309 |
if __name__ == "__main__":
|
310 |
-
demo.launch(
|
|
|
114 |
except Exception as e:
|
115 |
return f"Error: {str(e)}"
|
116 |
|
117 |
+
def transcribe_audio_from_url(audio_url, api_key, request: gr.Request = None):
|
118 |
"""Transcribe audio/video files from a URL into text using Groq's Whisper model.
|
119 |
|
120 |
This tool converts spoken content from audio and video files into written text.
|
|
|
135 |
"""
|
136 |
try:
|
137 |
# First check for environment variable, then use provided API key
|
138 |
+
actual_api_key = os.environ.get("GROQ_API_KEY")
|
139 |
+
|
140 |
+
if not actual_api_key and request is not None:
|
141 |
+
# If request is provided, check for API key in headers
|
142 |
+
actual_api_key = request.headers.get("GROQ_API_KEY")
|
143 |
+
|
144 |
+
if not actual_api_key:
|
145 |
+
actual_api_key = api_key
|
146 |
|
147 |
# Validate API key
|
148 |
if not actual_api_key:
|
|
|
314 |
""")
|
315 |
|
316 |
if __name__ == "__main__":
|
317 |
+
demo.launch()
|