Spaces:
Runtime error
Runtime error
Update inference.py
Browse files- inference.py +6 -6
inference.py
CHANGED
@@ -15,10 +15,10 @@ def query(filename, lang):
|
|
15 |
|
16 |
if (lang == 'ha') and (filename is not None):
|
17 |
API_URL = "https://api-inference.huggingface.co/models/Tiamz/hausa-4-ha-wa2vec-data-aug-xls-r-300m"
|
18 |
-
|
19 |
-
|
20 |
try:
|
21 |
-
response = requests.request("POST", API_URL, headers=headers, data=
|
22 |
command = json.loads(response.content.decode("utf-8"))
|
23 |
command = command['text']
|
24 |
if command != '':
|
@@ -32,11 +32,11 @@ def query(filename, lang):
|
|
32 |
|
33 |
elif (lang == 'yo') and (filename is not None):
|
34 |
API_URL = "https://api-inference.huggingface.co/models/Ayoola/cdial-yoruba-test"
|
35 |
-
|
36 |
-
|
37 |
|
38 |
try:
|
39 |
-
response = requests.request("POST", API_URL, headers=headers, data=
|
40 |
command = json.loads(response.content.decode("utf-8"))
|
41 |
command = command['text']
|
42 |
if command != '':
|
|
|
15 |
|
16 |
if (lang == 'ha') and (filename is not None):
|
17 |
API_URL = "https://api-inference.huggingface.co/models/Tiamz/hausa-4-ha-wa2vec-data-aug-xls-r-300m"
|
18 |
+
with open(filename, "rb") as f:
|
19 |
+
data = f.read()
|
20 |
try:
|
21 |
+
response = requests.request("POST", API_URL, headers=headers, data=data)
|
22 |
command = json.loads(response.content.decode("utf-8"))
|
23 |
command = command['text']
|
24 |
if command != '':
|
|
|
32 |
|
33 |
elif (lang == 'yo') and (filename is not None):
|
34 |
API_URL = "https://api-inference.huggingface.co/models/Ayoola/cdial-yoruba-test"
|
35 |
+
with open(filename, "rb") as f:
|
36 |
+
data = f.read()
|
37 |
|
38 |
try:
|
39 |
+
response = requests.request("POST", API_URL, headers=headers, data=data)
|
40 |
command = json.loads(response.content.decode("utf-8"))
|
41 |
command = command['text']
|
42 |
if command != '':
|