import gradio as gr import os from groq import Groq # Get API key from user input (hidden) api_key = gr.Textbox(label="Enter Your Groq API Key", type="password") def transcribe_audio(api_key, audio_file=None): client = Groq(api_key=api_key) # Initialize Groq client with user-provided key if audio_file is not None: 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 else: return "No audio file provided." # Interface for audio file upload and transcription demo = gr.Interface( fn=transcribe_audio, inputs=[ api_key, # Add API key input gr.File(label="Upload Audio File"), ], outputs=gr.Textbox(label="Transcribed Text"), title="Audio Transcription HNM", description="Upload an audio file to transcribe it into text", ) if __name__ == "__main__": demo.launch() """ ## How to use this app: 1. Enter your [Groq API Key](https://console.groq.com/keys) in the provided field. 2. Click on the upload section and provide a supported audio file. Supported audio files include mp3, mp4, mpeg, mpga, m4a, wav, and webm file types. 3. Click the "Process" button to transcribe your speech and generate a response from our AI assistant. 4. The transcription and AI assistant response will appear in the respective text boxes. """