Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,7 +9,7 @@ AUTH_TOKEN = os.getenv('AUTH_TOKEN')
|
|
9 |
|
10 |
def transcribe_audio(file_path):
|
11 |
if not ASR_API_URL or not AUTH_TOKEN:
|
12 |
-
return "Error: Missing ASR_API_URL or AUTH_TOKEN."
|
13 |
|
14 |
# Prepare headers and data
|
15 |
headers = {
|
@@ -22,28 +22,27 @@ def transcribe_audio(file_path):
|
|
22 |
start_time = time.time()
|
23 |
# Send POST request
|
24 |
response = requests.post(ASR_API_URL, headers=headers, files=files)
|
25 |
-
inference_time = time.time() - start_time
|
26 |
|
27 |
# Check if response is successful
|
28 |
if response.status_code == 200:
|
29 |
-
|
|
|
|
|
30 |
else:
|
31 |
-
return f"Error: {response.status_code}, {response.text}"
|
32 |
-
|
33 |
-
|
34 |
-
description_text = """
|
35 |
-
The Gooya Persian ASR model is crazy fast and super [powerful](https://huggingface.co/spaces/navidved/open_persian_asr_leaderboard) when it comes to Persian ASR!
|
36 |
-
\nJust drop in a Persian audio file, and boom—we’ll hit you with the best transcription you can get! 🚀🔥
|
37 |
-
"""
|
38 |
|
39 |
|
40 |
# Set up the Gradio interface
|
41 |
gr.Interface(
|
42 |
fn=transcribe_audio,
|
43 |
-
inputs=gr.Audio(type="filepath"),
|
44 |
-
outputs=
|
|
|
|
|
|
|
45 |
title="Gooya v1.4 Persian ASR",
|
46 |
-
description=
|
47 |
The Gooya Persian ASR model is crazy fast and super [powerful](https://huggingface.co/spaces/navidved/open_persian_asr_leaderboard) when it comes to Persian ASR!
|
48 |
\nJust drop in a Persian audio file, and boom—we’ll hit you with the best transcription you can get! 🚀🔥
|
49 |
"""
|
|
|
9 |
|
10 |
def transcribe_audio(file_path):
|
11 |
if not ASR_API_URL or not AUTH_TOKEN:
|
12 |
+
return "Error: Missing ASR_API_URL or AUTH_TOKEN.", None
|
13 |
|
14 |
# Prepare headers and data
|
15 |
headers = {
|
|
|
22 |
start_time = time.time()
|
23 |
# Send POST request
|
24 |
response = requests.post(ASR_API_URL, headers=headers, files=files)
|
25 |
+
inference_time = time.time() - start_time # in seconds
|
26 |
|
27 |
# Check if response is successful
|
28 |
if response.status_code == 200:
|
29 |
+
transcription = response.json().get("transcription", "No transcription returned.")
|
30 |
+
inference_time_str = f"{response.json().get("time", "No inference time returned.")} seconds"
|
31 |
+
return transcription, inference_time_str
|
32 |
else:
|
33 |
+
return f"Error: {response.status_code}, {response.text}", None
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
# Set up the Gradio interface
|
37 |
gr.Interface(
|
38 |
fn=transcribe_audio,
|
39 |
+
inputs=gr.Audio(type="filepath"),
|
40 |
+
outputs=[
|
41 |
+
gr.Textbox(label="Transcription"),
|
42 |
+
gr.Textbox(label="Inference Time")
|
43 |
+
],
|
44 |
title="Gooya v1.4 Persian ASR",
|
45 |
+
description="""
|
46 |
The Gooya Persian ASR model is crazy fast and super [powerful](https://huggingface.co/spaces/navidved/open_persian_asr_leaderboard) when it comes to Persian ASR!
|
47 |
\nJust drop in a Persian audio file, and boom—we’ll hit you with the best transcription you can get! 🚀🔥
|
48 |
"""
|