Spaces:
Sleeping
Sleeping
Download src/utils/speaking_utils.py from ABAO77/Run_code_api: direct link, hf CLI and curl.
- Browser
- Download file 538 Bytes
-
https://huggingface.co/spaces/ABAO77/Run_code_api/resolve/5d88ac1a065fac4ae510cbf0940f7ac1622089bc/src/utils/speaking_utils.py
- Command line
-
hf download hf://spaces/ABAO77/Run_code_api@5d88ac1a065fac4ae510cbf0940f7ac1622089bc/src/utils/speaking_utils.py
-
curl -L -o speaking_utils.py https://huggingface.co/spaces/ABAO77/Run_code_api/resolve/5d88ac1a065fac4ae510cbf0940f7ac1622089bc/src/utils/speaking_utils.py
538 Bytes
| import numpy as np | |
| import nltk | |
| def convert_numpy_types(obj): | |
| """Convert numpy types to Python native types""" | |
| if isinstance(obj, np.integer): | |
| return int(obj) | |
| elif isinstance(obj, np.floating): | |
| return float(obj) | |
| elif isinstance(obj, np.ndarray): | |
| return obj.tolist() | |
| elif isinstance(obj, dict): | |
| return {key: convert_numpy_types(value) for key, value in obj.items()} | |
| elif isinstance(obj, list): | |
| return [convert_numpy_types(item) for item in obj] | |
| else: | |
| return obj | |