voice-to-text / app.py
arshadrana's picture
Update app.py
ae43f08 verified
raw
history blame
1.08 kB
import gradio as gr
import requests
# Function to send audio to Groq API and get transcription
def transcribe(audio):
# Load audio data
audio_data = audio.read()
# Replace these placeholders with your actual Groq API endpoint and headers
groq_api_endpoint = "https://api.groq.com/transcribe" # Example endpoint
headers = {
"Authorization": "Bearer YOUR_GROQ_API_KEY",
"Content-Type": "audio/wav",
}
# Send audio to Groq API
response = requests.post(groq_api_endpoint, headers=headers, data=audio_data)
# Parse response
if response.status_code == 200:
result = response.json()
return result.get("transcription", "No transcription available.")
else:
return f"Error: {response.status_code}, {response.text}"
# Gradio interface
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="microphone", type="file"),
outputs="text",
title="Voice to Text Converter",
description="Record your voice, and it will be transcribed into text using Groq API."
)
iface.launch()