Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,15 @@ from groq import Groq
|
|
| 5 |
# Predefined password
|
| 6 |
CORRECT_PASSWORD = "password123"
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
if not api_key or not audio_file:
|
| 13 |
-
return "
|
| 14 |
|
| 15 |
try:
|
| 16 |
client = Groq(api_key=api_key)
|
|
@@ -21,32 +24,20 @@ def process_input(password, api_key, audio_file):
|
|
| 21 |
temperature=1,
|
| 22 |
response_format="verbose_json",
|
| 23 |
)
|
| 24 |
-
return
|
| 25 |
except Exception as e:
|
| 26 |
-
return f"An error occurred: {str(e)}"
|
| 27 |
|
| 28 |
-
# Create the interface
|
| 29 |
iface = gr.Interface(
|
| 30 |
-
fn=
|
| 31 |
inputs=[
|
| 32 |
gr.Textbox(type="password", label="Password"),
|
| 33 |
gr.Textbox(label="Groq API Key", type="password"),
|
| 34 |
gr.File(label="Upload Audio File")
|
| 35 |
],
|
| 36 |
-
outputs=
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
gr.Audio(label="Audio File") # This will display the uploaded audio file
|
| 40 |
-
],
|
| 41 |
-
title="Audio Transcription App",
|
| 42 |
-
description="""
|
| 43 |
-
How to use this app:
|
| 44 |
-
1. Enter the correct password.
|
| 45 |
-
2. Enter your Groq API Key.
|
| 46 |
-
3. Upload a supported audio file (mp3, mp4, mpeg, mpga, m4a, wav, or webm).
|
| 47 |
-
4. Click "Submit" to transcribe your speech.
|
| 48 |
-
5. The transcription will appear in the "Transcribed Text" box.
|
| 49 |
-
"""
|
| 50 |
)
|
| 51 |
|
| 52 |
if __name__ == "__main__":
|
|
|
|
| 5 |
# Predefined password
|
| 6 |
CORRECT_PASSWORD = "password123"
|
| 7 |
|
| 8 |
+
def check_password(password):
|
| 9 |
+
return password == CORRECT_PASSWORD
|
| 10 |
+
|
| 11 |
+
def transcribe_audio(password, api_key, audio_file):
|
| 12 |
+
if not check_password(password):
|
| 13 |
+
return "Incorrect password. Access denied."
|
| 14 |
|
| 15 |
if not api_key or not audio_file:
|
| 16 |
+
return "Please provide both API key and audio file."
|
| 17 |
|
| 18 |
try:
|
| 19 |
client = Groq(api_key=api_key)
|
|
|
|
| 24 |
temperature=1,
|
| 25 |
response_format="verbose_json",
|
| 26 |
)
|
| 27 |
+
return transcription.text
|
| 28 |
except Exception as e:
|
| 29 |
+
return f"An error occurred: {str(e)}"
|
| 30 |
|
|
|
|
| 31 |
iface = gr.Interface(
|
| 32 |
+
fn=transcribe_audio,
|
| 33 |
inputs=[
|
| 34 |
gr.Textbox(type="password", label="Password"),
|
| 35 |
gr.Textbox(label="Groq API Key", type="password"),
|
| 36 |
gr.File(label="Upload Audio File")
|
| 37 |
],
|
| 38 |
+
outputs=gr.Textbox(label="Result"),
|
| 39 |
+
title="Password Protected Audio Transcription App",
|
| 40 |
+
description="Enter the correct password to access the app. Then provide your Groq API key and upload an audio file to transcribe."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
)
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|