Package: slashml
SlashML Python clientSlashMLOne API for all your machine learning needs.Installation guidepip install slashmlQuickstartConvert text to audiofromslashmlimportTextToSpeech# Replace `API_KEY` with your SlasML API token. This example still runs without# the API token but usage will be limitedmodel=TextToSpeech(api_key=None)input_text="to be or not to be, that is the question!"# Submit requestjob=model.execute(text=input_text,service_provider=TextToSpeech.ServiceProvider.AWS)print(f"\n\n\nYou can access the audio file here:{job.audio_url}")Transcribe an audio filefromslashmlimportSpeechToText# Replace `API_KEY` with your SlasML API token. This example still runs without# the API token but usage will be limitedmodel=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 inputfromslashmlimportTextSummarizationmodel=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 ModelNote: this examples requires thetransformersandtorchpackages to be installed. You can install them withpip install transformers torchpip install transformers torchfromslashmlimportModelDeploymentimporttime# you might have to install transfomers and torchfromtransformersimportpipelinedeftrain_model():# Bring in model from huggingfacereturnpipeline('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 modelresponse=model.deploy(model_name='my_model_3',model=my_model)# wait for it to be deployedtime.sleep(2)status=model.status(model_version_id=response.id)whilestatus.status!='READY':print(f'status:{status.status}')print('trying again in 5 seconds')time.sleep(5)status=model.status(model_version_id=response.id)ifstatus.status=='FAILED':raiseException('Model deployment failed')# submit predictioninput_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 availablefromslashmlimportTextToSpeechprint(TextToSpeech.ServiceProvider.choices())# you can repeat the same thing for all services# print(TextSummarization.ServiceProvider.choices())# print(SpeechToText.ServiceProvider.choices())IntroductionOverviewThis is the Python client (SDK) for SlashML. It allows users to use the endpoints available and activehttps://docs.slashml.com.Set up and usageThere 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 fromhttps://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.fromslashmlimportTextToSpeech# Initialize modeltext_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 availablehere.Available service providersSpeech-to-textFor transcription, SlashML supports the following service providers:AssemblyAIAWSWhisper (OpenAI)GOOGLEDEEPGRAMREVSummarizationFor text summarization, SlashML supports the following service providers:Meta Bart (thruHuggin-face)Da-Vinci (OpenAI)Text-to-SpeechFor speechification, SlashML supports the following service providers:GoogleAWSDocumentationFor production ready use cases, look at theexamplesfolder