Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def transcribe_audio(file):
|
|
|
|
|
|
|
5 |
# Prepare headers and data
|
6 |
headers = {
|
7 |
'accept': 'application/json',
|
8 |
-
'Authorization': AUTH_TOKEN,
|
9 |
}
|
10 |
files = {
|
11 |
'file': (file.name, file, 'audio/mpeg'),
|
@@ -23,8 +31,8 @@ def transcribe_audio(file):
|
|
23 |
# Set up the Gradio interface
|
24 |
gr.Interface(
|
25 |
fn=transcribe_audio,
|
26 |
-
inputs=gr.Audio(type="file"),
|
27 |
outputs="text",
|
28 |
-
title="Persian ASR Transcription",
|
29 |
-
description="Upload an audio file in Persian, and this
|
30 |
).launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
+
import os
|
4 |
+
|
5 |
+
# Retrieve ASR API URL and Authorization Token from environment variables
|
6 |
+
ASR_API_URL = os.getenv('ASR_API_URL')
|
7 |
+
AUTH_TOKEN = os.getenv('AUTH_TOKEN')
|
8 |
|
9 |
def transcribe_audio(file):
|
10 |
+
if not ASR_API_URL or not AUTH_TOKEN:
|
11 |
+
return "Error: Missing ASR_API_URL or AUTH_TOKEN."
|
12 |
+
|
13 |
# Prepare headers and data
|
14 |
headers = {
|
15 |
'accept': 'application/json',
|
16 |
+
'Authorization': f'Bearer {AUTH_TOKEN}',
|
17 |
}
|
18 |
files = {
|
19 |
'file': (file.name, file, 'audio/mpeg'),
|
|
|
31 |
# Set up the Gradio interface
|
32 |
gr.Interface(
|
33 |
fn=transcribe_audio,
|
34 |
+
inputs=gr.Audio(type="file"),
|
35 |
outputs="text",
|
36 |
+
title="Gooya v1 Persian ASR Transcription",
|
37 |
+
description="Upload an audio file in Persian, and this Model will transcribe it."
|
38 |
).launch()
|