Rest api supporter
Project description
rest-api-supporter
https://pypi.org/project/rest-api-supporter/
pip install rest-api-supporter
Supported APIs
base64 encode
from PIL import Image
from rest_api_supporter.utils.base64_encode import base64_encode
image = Image.open("rock.jpg")
base64_encoded = base64_encode(image)
print(base64_encoded) #data:image/png;base64,/9j/4AAQSkZJRgABAQ...2qjR37P/2Q==
import datasets
from rest_api_supporter.utils.base64_encode import base64_encode
path = 'up.wav'
dataset = datasets.Dataset.from_dict({"audio": [path]})
dataset = dataset.cast_column("audio", datasets.Audio(sampling_rate=16_000)) #https://huggingface.co/blog/audio-datasets#1-resampling-the-audio-data
array = dataset[0]["audio"]["array"] #numpy array
#sampling_rate = dataset[0]["audio"]["sampling_rate"] #Wav2Vec2FeatureExtractor was trained using a sampling rate of 16000. Please make sure that the provided `raw_speech` input was sampled with 16000 and not 8000.
sampling_rate = 16000
base64_encoded = base64_encode(array)
print(base64_encoded) #data:audio/wav;base64,UklGRiTuAgBXQVZFZm...At84WACNZGwA=
base64 decode
from rest_api_supporter.utils.base64_decode import base64_decode
print(full_encoded) #data:image/png;base64,/9j/4AAQSkZJRgABAQ...2qjR37P/2Q==
#data:audio/wav;base64,UklGRiTuAgBXQVZFZm...At84WACNZGwA=
#/9j/4AAQSkZJRgABAQ...2qjR37P/2Q==
base64_decoded = base64_decode(full_encoded)
print(type(base64_decoded)) #<class 'PIL.JpegImagePlugin.JpegImageFile'>
#<class 'bytes'>
#<class 'PIL.JpegImagePlugin.JpegImageFile'>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rest-api-supporter-0.0.21.tar.gz
.
File metadata
- Download URL: rest-api-supporter-0.0.21.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc4dbce34aa595c3fa639ce18355301f13d8e3c41ce6579c943fa42b4c40d076 |
|
MD5 | 9dd1679ea22db7eefb962dacbd5f9421 |
|
BLAKE2b-256 | 26a8f37f5aaccf24e2a9d2e435fdce6890fc525c4afccba8aaec36129a0f5151 |
File details
Details for the file rest_api_supporter-0.0.21-py3-none-any.whl
.
File metadata
- Download URL: rest_api_supporter-0.0.21-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2cdd9d5f92a05a6c4a2327eccf81c15e4d890e7b07db34058c7d4cd602f3a28 |
|
MD5 | a8af61874f641eeb3128c22ffbb3532e |
|
BLAKE2b-256 | 6f35a9859a93c8305a4a9a95e0906149d6dc1c6bcf557d75b5df01a9597b5ebe |