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 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'>

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 = base64_encode(array) 
print(base64) #data:audio/wav;base64,UklGRiTuAgBXQVZFZm...At84WACNZGwA=

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.16.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

rest_api_supporter-0.0.16-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rest-api-supporter-0.0.16.tar.gz
Algorithm Hash digest
SHA256 df0ec48e93a068fc6b891854970fb9b0d93f68524d53ec100039e149bcf531d9
MD5 70858ab3551fbf81273f9b500d20c020
BLAKE2b-256 043d81b5973220b26e953a11fa562ee3f0dc31f8db7340385a5e5b02f91ecd5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rest_api_supporter-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 0c93f788fd1a2ef55ea9adaa473ddb59bd304af3dff448ec35291aa880d42fd9
MD5 7c3c613f9f2f351e02e6f1d9e95bc9cf
BLAKE2b-256 0683846d5b8a1d9e19934f2c20c9c836df99afec15dcf1de313e175e0d6583e9

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