Spaces:
Runtime error
Runtime error
Update inference.py
Browse files- inference.py +6 -7
inference.py
CHANGED
@@ -11,7 +11,6 @@ def query(filename, lang):
|
|
11 |
Function to get inference for three languages
|
12 |
|
13 |
"""
|
14 |
-
|
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"
|
@@ -22,12 +21,12 @@ def query(filename, lang):
|
|
22 |
command = json.loads(response.content.decode("utf-8"))
|
23 |
command = command['text']
|
24 |
if command != '':
|
25 |
-
print(command)
|
26 |
return command
|
27 |
else:
|
28 |
print('No response yet')
|
29 |
except KeyError as e:
|
30 |
-
|
31 |
|
32 |
elif (lang == 'yo') and (filename is not None):
|
33 |
API_URL = "https://api-inference.huggingface.co/models/Ayoola/cdial-yoruba-test"
|
@@ -39,12 +38,12 @@ def query(filename, lang):
|
|
39 |
command = json.loads(response.content.decode("utf-8"))
|
40 |
command = command['text']
|
41 |
if command != '':
|
42 |
-
print(command)
|
43 |
return command
|
44 |
else:
|
45 |
pass
|
46 |
except KeyError as e:
|
47 |
-
|
48 |
|
49 |
elif (lang == 'en') and (filename is not None):
|
50 |
API_URL = "https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h"
|
@@ -55,11 +54,11 @@ def query(filename, lang):
|
|
55 |
command = json.loads(response.content.decode("utf-8"))
|
56 |
command = command['text']
|
57 |
if command != '':
|
58 |
-
print(command)
|
59 |
return command.lower()
|
60 |
else:
|
61 |
print('No response yet')
|
62 |
except KeyError as e:
|
63 |
-
|
64 |
else:
|
65 |
pass
|
|
|
11 |
Function to get inference for three languages
|
12 |
|
13 |
"""
|
|
|
14 |
|
15 |
if (lang == 'ha') and (filename is not None):
|
16 |
API_URL = "https://api-inference.huggingface.co/models/Tiamz/hausa-4-ha-wa2vec-data-aug-xls-r-300m"
|
|
|
21 |
command = json.loads(response.content.decode("utf-8"))
|
22 |
command = command['text']
|
23 |
if command != '':
|
24 |
+
#print(command)
|
25 |
return command
|
26 |
else:
|
27 |
print('No response yet')
|
28 |
except KeyError as e:
|
29 |
+
return 'Model is still loading..., please wait!'
|
30 |
|
31 |
elif (lang == 'yo') and (filename is not None):
|
32 |
API_URL = "https://api-inference.huggingface.co/models/Ayoola/cdial-yoruba-test"
|
|
|
38 |
command = json.loads(response.content.decode("utf-8"))
|
39 |
command = command['text']
|
40 |
if command != '':
|
41 |
+
#print(command)
|
42 |
return command
|
43 |
else:
|
44 |
pass
|
45 |
except KeyError as e:
|
46 |
+
return 'Model is still loading..., please wait!'
|
47 |
|
48 |
elif (lang == 'en') and (filename is not None):
|
49 |
API_URL = "https://api-inference.huggingface.co/models/facebook/wav2vec2-base-960h"
|
|
|
54 |
command = json.loads(response.content.decode("utf-8"))
|
55 |
command = command['text']
|
56 |
if command != '':
|
57 |
+
#print(command)
|
58 |
return command.lower()
|
59 |
else:
|
60 |
print('No response yet')
|
61 |
except KeyError as e:
|
62 |
+
return 'Model is still loading..., please wait!'
|
63 |
else:
|
64 |
pass
|