Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rest-api-supporter-0.0.23.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

rest_api_supporter-0.0.23-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file rest-api-supporter-0.0.23.tar.gz.

File metadata

  • Download URL: rest-api-supporter-0.0.23.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for rest-api-supporter-0.0.23.tar.gz
Algorithm Hash digest
SHA256 6087554cecef2e03ecf27f754961a7c0b2befe2f6ec125d18af62c3d627ffc68
MD5 0db5fa0d87d3cc3ee659a046a7de1177
BLAKE2b-256 7b2fa773b9b40bf07e74e7ec1173a30b5927c2c0aabcdff2cac08862179eaf98

See more details on using hashes here.

File details

Details for the file rest_api_supporter-0.0.23-py3-none-any.whl.

File metadata

File hashes

Hashes for rest_api_supporter-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 f571778ca8ee67c960c163e2726bc83e7ec8dfbbff02da10df0a3f08d229ecd9
MD5 4c9b16060e72c1742d780e35b1826dba
BLAKE2b-256 62d08ac6607f1f45d3373aa5b76ea15ba801c2de30cdc0ee2ff9b3ad834c8d1d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page