Spaces:
Running
Running
File size: 1,134 Bytes
309b067 ae43f08 309b067 ae43f08 ebcc9f2 ae43f08 0fe9a40 ae43f08 309b067 ae43f08 309b067 ae43f08 ebcc9f2 309b067 ae43f08 309b067 0fe9a40 |
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 |
import gradio as gr
import requests
# Function to send audio to Groq API and get transcription
def transcribe(audio_path):
# Read audio file in binary mode
with open(audio_path, "rb") as audio_file:
audio_data = audio_file.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(type="filepath"),
outputs="text",
title="Voice to Text Converter",
description="Record your voice, and it will be transcribed into text using Groq API."
)
iface.launch()
|