Skip to main content

SlashML Python client

SlashML

One API for all your machine learning needs.

Installation guide

pip install slashml

Quickstart

Convert text to audio

from slashml import TextToSpeech

# Replace `API_KEY` with your SlasML API token. This example still runs without
# the API token but usage will be limited
model = TextToSpeech(api_key=None)

input_text = "to be or not to be, that is the question!"

# Submit request
job = model.execute(text=input_text, service_provider=TextToSpeech.ServiceProvider.AWS)

print (f"\n\n\n You can access the audio file here: {job.audio_url}")

Transcribe an audio file

from slashml import SpeechToText

# Replace `API_KEY` with your SlasML API token. This example still runs without
# the API token but usage will be limited
model = SpeechToText(api_key=None)

response = model.execute(
    upload_url='https://slashml.s3.ca-central-1.amazonaws.com/695c711f-9f5d-4ff1-ae4f-4439842eef5f', 
    service_provider=SpeechToText.ServiceProvider.WHISPER
)

print(f"\n\n\n\nTranscription = {response.transcription_data.transcription}")

Summarize a text input

from slashml import TextSummarization

model = TextSummarization(api_key=None)

input_text = """A good writer doesn't just think, and then write down what he thought, as a sort of transcript. A good writer will almost always discover new things in the process of writing. And there is, as far as I know, no substitute for this kind of discovery. Talking about your ideas with other people is a good way to develop them. But even after doing this, you'll find you still discover new things when you sit down to write. There is a kind of thinking that can only be done by writing."""

response = model.execute(text=input_text, service_provider=TextSummarization.ServiceProvider.OPENAI)

print(f"Summary = {response.summarization_data}")

Deploy your own Model

Note: this examples requires the transformers and torch packages to be installed. You can install them with pip install transformers torch

pip install transformers torch
from slashml import ModelDeployment
import time

# you might have to install transfomers and torch
from transformers import pipeline

def train_model():
    # Bring in model from huggingface
    return pipeline('fill-mask', model='bert-base-uncased')

my_model = train_model()

# Replace `API_KEY` with your SlasML API token.
API_KEY = "YOUR_API_KEY"

model = ModelDeployment(api_key=API_KEY)

# deploy model
response = model.deploy(model_name='my_model_3', model=my_model)

# wait for it to be deployed
time.sleep(2)
status = model.status(model_version_id=response.id)

while status.status != 'READY':
    print(f'status: {status.status}')
    print('trying again in 5 seconds')
    time.sleep(5)
    status = model.status(model_version_id=response.id)

    if status.status == 'FAILED':
        raise Exception('Model deployment failed')

# submit prediction
input_text = 'Steve jobs is the [MASK] of Apple.'
prediction = model.predict(model_version_id=response.id, model_input=input_text)
print(prediction)

View the list of service providers available

from slashml import TextToSpeech

print(TextToSpeech.ServiceProvider.choices())

# you can repeat the same thing for all services 
# print(TextSummarization.ServiceProvider.choices())
# print(SpeechToText.ServiceProvider.choices())

Introduction

Overview

This is the Python client (SDK) for SlashML. It allows users to use the endpoints available and active https://docs.slashml.com.

Set up and usage

There is a daily limit (throttling) on the number of calls the user performs. The code can run without specifying the API key. The throttling kicks in and prevents new jobs after exceeding 10 calls per minute.

If the user intends on using the service more frequently, it is recommended to generate an token or API key from https://www.slashml.com/settings/api-key. You can pass the API key when creating a model, if you don't the api will still work but you will be throttled.

from slashml import TextToSpeech

# Initialize model
text_to_speech = TextToSpeech(api_key="YOUR_API_KEY")

# summarizer = TextSummarization(api_key="YOUR_API_KEY")
# speech_to_text = SpeechToText(api_key="YOUR_API_KEY")

If the user preferes using the API calls directly, the documentation is available here.

Available service providers

Speech-to-text

For transcription, SlashML supports the following service providers:

Summarization

For text summarization, SlashML supports the following service providers:

Text-to-Speech

For speechification, SlashML supports the following service providers:

Documentation

For production ready use cases, look at the examples folder

Metadata

Release files for slashml 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slashml 0.1.4
File Size Uploaded
slashml-0.1.4.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slashml 0.1.4
File Interpreter ABI Platform
slashml-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / slashml-0.1.4.tar.gz

Download URL slashml-0.1.4.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5f634009a01d76469fadaf498804fa32461e75ee9cd21fac6bd965d8c2738aeb
BLAKE2b-256 checksum
How to use checksums
347b173afa7b765300f855dece48699168c67fb28d0cb8eeb51956d7030cb34a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.3

Release files / slashml-0.1.4-py3-none-any.whl

Download URL slashml-0.1.4-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c518142273f3fb0c377d2f1eb510abc46f9e35d626e50304cb3958e6c1e030f
BLAKE2b-256 checksum
How to use checksums
48a3a16a6b81f965fa442fb35b14f04675d252a4f89a7b7cf18182d0498b7fde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.3

Release history Release notifications | RSS feed

0.1.6

2 release files

0.1.5

2 release files

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.0

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page