|
|
import gradio as gr |
|
|
import os |
|
|
from groq import Groq |
|
|
|
|
|
|
|
|
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) |
|
|
|
|
|
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." |
|
|
|
|
|
|
|
|
demo = gr.Interface( |
|
|
fn=transcribe_audio, |
|
|
inputs=[ |
|
|
api_key, |
|
|
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() |
|
|
|