File size: 1,476 Bytes
4e03ccf d025f75 5b71105 c2c2101 5b71105 c2c2101 ba40e2e 5b71105 ba40e2e 5b71105 4e03ccf c2c2101 ba40e2e c2c2101 ba40e2e c2c2101 ba40e2e c2c2101 5b71105 ba40e2e 5d4ee50 ba40e2e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import gradio as gr
import os
from groq import Groq
# Predefined password
CORRECT_PASSWORD = "password123"
# Get the Groq API key from the environment variable
GROQ_API_KEY = os.environ.get("GROQ_API_KEY")
def check_password(password):
return password == CORRECT_PASSWORD
def transcribe_audio(password, audio_file):
if not check_password(password):
return "Incorrect password. Access denied."
if not audio_file:
return "Please provide an audio file."
if not GROQ_API_KEY:
return "Groq API key not found in environment variables."
try:
client = Groq(api_key=GROQ_API_KEY)
with open(audio_file.name, "rb") as file:
transcription = client.audio.transcriptions.create(
file=(audio_file.name, file.read()),
model="whisper-large-v3",
temperature=1,
response_format="verbose_json",
)
return transcription.text
except Exception as e:
return f"An error occurred: {str(e)}"
iface = gr.Interface(
fn=transcribe_audio,
inputs=[
gr.Textbox(type="password", label="Password"),
gr.File(label="Upload Audio File")
],
outputs=gr.Textbox(label="Result"),
title="Password Protected Audio Transcription App",
description="Enter the correct password to access the app. Then upload an audio file to transcribe."
)
if __name__ == "__main__":
iface.launch(share=True) |