Spaces:
Sleeping
Sleeping
File size: 881 Bytes
65f9ac9 aba8804 d6c20cc aba8804 2227fad aba8804 2227fad aba8804 2227fad aba8804 |
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 |
import gradio as gr
import requests
import os
def send_audio_to_laravel(audio):
url = os.getenv("BASE_URL") # Make sure to set this environment variable or replace with the actual URL
# Save audio to a temporary file
temp_audio_path = "temp_audio.wav"
audio.save(temp_audio_path)
# Prepare form data for request
files = {
'file': open(temp_audio_path, 'rb'),
}
data = {
'lang': 'english-twi' # You can adjust this based on your needs
}
response = requests.post(url, files=files, data=data)
return response.json()
# Gradio interface for recording speech
iface = gr.Interface(
fn=send_audio_to_laravel,
inputs=gr.Audio(source="microphone", type="filepath"),
outputs="text",
title="Speech Translation",
description="Record speech and send it to Laravel for processing.",
)
iface.launch()
|