Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,17 @@ def transcribe_audio(api_key, file_path):
|
|
13 |
with open(file_path, "rb") as f:
|
14 |
data = f.read()
|
15 |
response = requests.post(API_URL, headers=headers, data=data)
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Function to get YouTube transcript
|
19 |
def get_transcript(url):
|
|
|
13 |
with open(file_path, "rb") as f:
|
14 |
data = f.read()
|
15 |
response = requests.post(API_URL, headers=headers, data=data)
|
16 |
+
|
17 |
+
try:
|
18 |
+
if response.status_code != 200:
|
19 |
+
return f"Error: Received status code {response.status_code}"
|
20 |
+
if not response.content:
|
21 |
+
return "Error: Empty response from server"
|
22 |
+
if 'application/json' not in response.headers.get('Content-Type', ''):
|
23 |
+
return "Error: Response is not in JSON format"
|
24 |
+
return response.json().get("text", "Error: Could not transcribe audio")
|
25 |
+
except requests.exceptions.JSONDecodeError:
|
26 |
+
return "Error: Could not decode JSON response"
|
27 |
|
28 |
# Function to get YouTube transcript
|
29 |
def get_transcript(url):
|