gooya-v1 / app.py
navidved's picture
Update app.py
eb44037 verified
import gradio as gr
import requests
import os
# Retrieve ASR API URL and Authorization Token from environment variables
ASR_API_URL = os.getenv('ASR_API_URL')
AUTH_TOKEN = os.getenv('AUTH_TOKEN')
def transcribe_audio(file_path):
if not ASR_API_URL or not AUTH_TOKEN:
return "Error: Missing ASR_API_URL or AUTH_TOKEN."
# Prepare headers and data
headers = {
'accept': 'application/json',
'Authorization': f'Bearer {AUTH_TOKEN}',
}
files = {
'file': (file_path, open(file_path, 'rb'), 'audio/mpeg'),
}
# Send POST request
response = requests.post(ASR_API_URL, headers=headers, files=files)
# Check if response is successful
if response.status_code == 200:
return response.json().get("transcription", "No transcription returned.")
else:
return f"Error: {response.status_code}, {response.text}"
description_text = """
The Gooya model is one of the most [powerful](https://huggingface.co/spaces/navidved/open_persian_asr_leaderboard) and fastest Persian ASR models.
Upload an audio file in Persian, and this Model will transcribe it.
"""
# Set up the Gradio interface
gr.Interface(
fn=transcribe_audio,
inputs=gr.Audio(type="filepath"), # Updated here
outputs="text",
title="Gooya v1.2 Persian ASR",
description="The Gooya model is one of the most powerful and fastest Persian ASR models. Upload an audio file in Persian, and this Model will transcribe it."
).launch()