Spaces:
Sleeping
Sleeping
Download app.py from kashif1312/Kashif_Programmer: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/spaces/kashif1312/Kashif_Programmer/resolve/main/app.py
- Command line
-
hf download hf://spaces/kashif1312/Kashif_Programmer/app.py
-
curl -L -o app.py https://huggingface.co/spaces/kashif1312/Kashif_Programmer/resolve/main/app.py
1.15 kB
| import gradio as gr | |
| from groq import Groq | |
| # π HARD-CODED GROQ API KEY (NOT SAFE FOR PUBLIC PRODUCTION) | |
| GROQ_API_KEY = "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" | |
| client = Groq(api_key=GROQ_API_KEY) | |
| def speech_to_text(audio_file): | |
| if audio_file is None: | |
| return "β Please upload an audio file." | |
| try: | |
| with open(audio_file, "rb") as f: | |
| transcription = client.audio.transcriptions.create( | |
| file=f, | |
| model="whisper-large-v3" | |
| ) | |
| return transcription.text | |
| except Exception as e: | |
| return f"β Error: {str(e)}" | |
| with gr.Blocks(title="AI Speech to Text - Groq") as app: | |
| gr.Markdown("# π€ AI Speech to Text Converter") | |
| gr.Markdown("Powered by **Muhammad Kashif") | |
| audio_input = gr.Audio( | |
| label="Upload Audio File", | |
| type="filepath" | |
| ) | |
| convert_btn = gr.Button("Convert to Text") | |
| output_text = gr.Textbox( | |
| label="π Transcribed Text", | |
| lines=10 | |
| ) | |
| convert_btn.click( | |
| fn=speech_to_text, | |
| inputs=audio_input, | |
| outputs=output_text | |
| ) | |
| app.launch() | |