From fcfcb6c0d8c8e7df909b2c9c3d314845a752dfbf Mon Sep 17 00:00:00 2001 From: JJneid Date: Tue, 27 Dec 2022 19:48:51 -0500 Subject: [PATCH 1/4] speech to text sdk --- .DS_Store | Bin 6148 -> 0 bytes README.md | 75 +++++++++++++++- SDK_v1/.DS_Store | Bin 6148 -> 0 bytes .../__pycache__/speechtotext.cpython-310.pyc | Bin 2164 -> 0 bytes SDK_v1/readme.md | 44 --------- SDK_v1/speechtotext.py | 58 ------------ SDK_v1/test_speechtotext.py | 51 ----------- src/LICENSE.txt | 21 +++++ src/requirements.txt | 1 + src/speechtotext.py | 85 ++++++++++++++++++ src/test_speechtotext_1.py | 21 +++++ 11 files changed, 201 insertions(+), 155 deletions(-) delete mode 100644 .DS_Store delete mode 100644 SDK_v1/.DS_Store delete mode 100644 SDK_v1/__pycache__/speechtotext.cpython-310.pyc delete mode 100644 SDK_v1/readme.md delete mode 100644 SDK_v1/speechtotext.py delete mode 100644 SDK_v1/test_speechtotext.py create mode 100644 src/LICENSE.txt create mode 100644 src/requirements.txt create mode 100644 src/speechtotext.py create mode 100644 src/test_speechtotext_1.py diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index ed35149ac416aee35c903e918e5c52136a4d9362..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKL2KJE6n<*GR%sddut6^cL$4u?=@>2B!A;%67`@bEJ#-_B>yVn+mPwrE5CT4T zKW5jRcG_>)uPJozNixiC*PS-nq6bf(r1w5q`ivzD09bDtxd1i*aCAaz4U1ch;^a4M zN%s(s(HL(MaTX>b#5N6R%qUoe)V_)d%7GcsT3Z&kjUZ4B~7!mV`JOV#L{DR>5PQ&=q9Q6P(^m|pZw^e+G4AR7QlX*)lTXHR^plysp)h^%V2(@&<|#C# zQNSorS72E+Z94xC|9tsettings> new api key) and authenticate by setting it as an environment variable (or when you initialize the service, see examples): +``` +export SLASHML_API_KEY=[token] +``` +or including it in your code as follows: +``` +import speechtotext +API_KEY="your_api_key" +speect_to_text = speechtotext.SpeechToText(API_KEY) +transcribe_id= speect_to_text.transcribe(audio_url,service_provider="aws") +status=speect_to_text.status(transcribe_id,service_provider=service_provider) + +``` + +-- update from this part, include examples, sign up, token, service providers, type of servies, benchmarking, link to pricing, Tutorial examples/examples + + +SDK for SlashML documentation: +- methods: upload_audio, transcribe, status + +Steps to Integrate +1 - (Optional) Upload files where the data points to your audio file +``` +# call the class +speect_to_text = speechtotext.SpeechToText() +file_location="path/to/your/file.mp3" +# when +API_KEY="SLASH_ML_API_KEY" +model_choice="assembly" +result_upload = speect_to_text.upload_audio(file_location,API_KEY, model_choice) +print(result_upload) +``` +Save the upload_url. You can use this url link in the rest of the calls. + + +2- Submit your audio file for transcription +``` +upload_url=upload_url # you can skip step 1 and just input the accessible link of your # file) + +result_transcribe = speect_to_text.transcribe(upload_url,API_KEY, model_choice) + +print(result_transcribe) +``` +Save the id in the response object. + + +3 - Check the status and get the text result of the transcription +``` +job_id= id +result_status = speect_to_text.status(job_id,API_KEY, model_choice=model_choice) + +### get the full details of the result +print(result_status) +### get the text reulst only +print(json.loads(result)["text"]) +``` + + +et voilà, Next steps: +- pip install slashml +- add SLASH_API_KEY to sys path diff --git a/SDK_v1/.DS_Store b/SDK_v1/.DS_Store deleted file mode 100644 index e6517a46c43905e5e3a4d765057fe5c26cf4217a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO^Xvj5UtKeGchdYunT(;2E2xtup+zcWr*v+s}Vh@j5C?R4bD!7%)}@mFz5Bh zc=ea~Up(on>R!l)3ko6w?EVmw zg|x8OL*ep{7Y4Viv()$BW5x4gV(0oAPqJ}Q_Ilq`ZLfaocEf9UE$_|nLeGa~RL+V) zG=0Uj=UQj+bvcS(jMI78K6tG2G8*UUR0!iFMat`!<2=#xfu7|_A>5(q@S0vTY#%Ka z$EU{~|50z*@fZDm|Fq+uoIG4Eo8IC52WQX1_t|BxuVmGvaN3FOTfBzPDBPgQhv78O zbj}JgyGc{19Z^D;z%F94p&F01s`Xu*trO&?qH{@FzSl=Y`FiVY`m(`3SoyktFpj#n zF%GKEc0>XDEB0DDvL3e#r+`!7?PRc$$l$}}G7mAYEF}^S9qymF3It82p>k90dYMbx> zCpW+U*GaDC6mSaclme=LK0F^_N%n5tS{&cCKKw15jq@slLP43j9+Aega4xn}YxV diff --git a/SDK_v1/__pycache__/speechtotext.cpython-310.pyc b/SDK_v1/__pycache__/speechtotext.cpython-310.pyc deleted file mode 100644 index 180fbdc1f274bdc7e816cb8089ef86708cf7a9cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2164 zcma)7&2tks6yMc;+So}j;1v2rOTV@)*)pB!fngX7$rM6xGqH2%UNjp^iPx-mjU+S0 z-JIam8UBK{GjQZz(zU1l3mn?Mw;Lxhr8Cuzp7gX&(tE%6p}g6w8_*;j4zBoy@dq-e zn+41*=<+%cW-v1~#%5%iI43EINI6=O1*4VPV<&P<<9mbI%z0)o=P8L?MtVlz{t5ey zz|@URnP)p(PV!9hE-cvFu^JBW@9E|Oa|^os1qe4HlNk}&h5I9mTa2t4kqx5-qXVN2 zqstuTJ~JXOF(RMWc%6AS47SSZ?94MeI>Q>g!J5#Qcw^sX%WMT!o9yhuYKxtN)g^X* zVf6xQ!|F1tfgSJYMsLFTVA#+5{3kUFhDuH3^)QSl$(l@KIUJ{JgM1vyQtGP8uPTrW zA77jK;dGMbF$-snP>DE`1Ci|UaJF>JO;nO+0|FM$8_sR$cc9A_5M_+aUjc@qq`%vs z66wA+!+;2s)2-fCr+4?k7VY&r{oNkj-PsC=wk1#ZHA&bjL)1X*_3dz1av{Ub&5S23 zT<7wk$|qqD4S0}-+fURm&*+^r;h741>-Xv7YeyET9PL?~JkkD*G#>A<_~sc@4mE8V zvkRxuS({5}@9sutePgGmUBT5yCT3w!2rsbI>gr}Z z1=U0{ixI16d2ViJ`yRc&@nc|Xl1uIJ>~SLUOj`$Bi3Xe)n8Jghw7w!3_u8j4$r45B zGH|60ZSxHq<`TNOpQN0o`JlX7dq-F5#yDp@rGsIf4EO-;m^XwP1G)6xCQO+5!YII| zLz|JpPRv7xS%n3oiwUE^tIT~$n7423lLPb6Q)FZn#>g(5!Yw@JKerG4!XG(+MXmd~ z*3TdE?DEgw9Ev44Tsx&AkrPi@lFybDmx`A2wejRzO~l@;Ub5kM!VdyVdqW;Ghyrc1 zSjE~w`()s1cRv^7SZO<-@J#!HKbpc(AU4URI*G8|?X4d=>lk6$#+V3d6~yO27jYiR zg;FbpT8fJ}_a^ZZOabvOa&U502Hx~aqe_%Yd5n6A$JH(0^vxEr|MneX+NS%LYt1e$ z#M|k8x_-n>MfxwVIB;I+l^Za@YyuyEPma8UUUASXg;_vx`Hg@l%n<=kSfwAF=T_+l z%s#gp)k;(;+#@h}OJ@WmYE}1hR@qVhUxoj#NC}3x1oOZV@8OmYkbDS4x91Vv-|2LF zcXsY=_Yq?85lSB+{259gBOJBn)nuaRk+a0dD1w-aD@Z;;g5h{7_UrR)dmN?Z3J{;v z0b@c4pxbg>bGEvG@5v7Bj`BU4umxn{0Wpq|{SKJ_j`s@B7gk}uG%>oF4VZd`H$qIE z?g@|rArqeiS-|QnEa>;&g4Idgt042Mp!^a~Ifm^2z~f34tEmiOqr?h=z}OIcZG`3A z0xXpzl;9@Fb%PZwD_K0|lQA&XSN?XVw^6$IGVB&#Ai<&` zzCwaGLw+U$rI#s>yvmr%hm8ufh{cBxbN0rpcbLa2<=?+irump|biWmUf8> LGz`410r~q6S55zo diff --git a/SDK_v1/readme.md b/SDK_v1/readme.md deleted file mode 100644 index 7321fe1..0000000 --- a/SDK_v1/readme.md +++ /dev/null @@ -1,44 +0,0 @@ -SDK for SlashML documentation: -- methods: upload_audio, transcribe, status - -Steps to Integrate -1 - (Optional) Upload files where the data points to your audio file -``` -# call the class -speect_to_text = speechtotext.SpeechToText() -file_location="path/to/your/file.mp3" -# when -API_KEY="SLASH_ML_API_KEY" -model_choice="assembly" -result_upload = speect_to_text.upload_audio(file_location,API_KEY, model_choice) -print(result_upload) -``` -Save the upload_url. You can use this url link in the rest of the calls. - - -2- Submit your audio file for transcription -``` -upload_url=upload_url # you can skip step 1 and just input the accessible link of your # file) - -result_transcribe = speect_to_text.transcribe(upload_url,API_KEY, model_choice) - -print(result_transcribe) -``` -Save the id in the response object. - - -3 - Check the status and get the text result of the transcription -``` -job_id= id -result_status = speect_to_text.status(job_id,API_KEY, model_choice=model_choice) - -### get the full details of the result -print(result_status) -### get the text reulst only -print(json.loads(result)["text"]) -``` - - -et voilà, Next steps: -- pip install slashml -- add SLASH_API_KEY to sys path diff --git a/SDK_v1/speechtotext.py b/SDK_v1/speechtotext.py deleted file mode 100644 index fc96cbe..0000000 --- a/SDK_v1/speechtotext.py +++ /dev/null @@ -1,58 +0,0 @@ -from django.http import JsonResponse -import requests -import os -from pathlib import Path - -class SpeechToText: - # TODO: make sure this is dynamic - SLASHML_BASE_URL = 'https://api.slashml.com/speech-to-text/v1' - SLASHML_UPLOAD_URL = SLASHML_BASE_URL+'/upload/' - SLASHML_TRANSCRIPT_URL = SLASHML_BASE_URL+'/transcribe/' - SLASHML_STATUS_URL = SLASHML_BASE_URL+'/transcription' - SLASHML_TRANSCRIPT_STATUS_URL = lambda self,id: f"{SpeechToText.SLASHML_STATUS_URL}/{id}/" - - HEADERS:dict = {} - ## add the api key to sys path envs - def __init__(self) -> None: - self.HEADERS = {'authorization': os.environ.get('SLASHML_API_KEY')} - - def upload_audio(self, file_location:str, API_KEY: str, model_choice: str ): - # here we can also add the service? assemblyai, aws, gcp? - - token="Token {0}".format(API_KEY) - headers = {'authorization': token} - payload = { 'model':model_choice } - files=[ - ('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg')) - ] - #import pdb - #pdb.set_trace() - response = requests.post(self.SLASHML_UPLOAD_URL, - headers=headers, - data=payload,files=files) - return response.text - - def transcribe(self,upload_url:str, API_KEY: str, model_choice: str ): - # here we can add more model params - transcript_request = {'audio_url': upload_url} - token="Token {0}".format(API_KEY) - headers = {'authorization': token} - payload = { - "uploaded_audio_url": upload_url, - "model": model_choice - } - - response = requests.post(self.SLASHML_TRANSCRIPT_URL, headers=headers, data=payload) - return response.text - - def status(self,job_id:str, API_KEY: str, model_choice: str ): - token="Token {0}".format(API_KEY) - headers = {'authorization': token} - payload = { - "model": model_choice - } - #import pdb - # pdb.set_trace() - response = requests.get(self.SLASHML_TRANSCRIPT_STATUS_URL(job_id) , headers=headers, data=payload) - return response.text - diff --git a/SDK_v1/test_speechtotext.py b/SDK_v1/test_speechtotext.py deleted file mode 100644 index 34bd9c6..0000000 --- a/SDK_v1/test_speechtotext.py +++ /dev/null @@ -1,51 +0,0 @@ -#### unit testing -import pytest - -import json -def test_upload(): - import speechtotext - # given: there is a local file - speect_to_text = speechtotext.SpeechToText() - file_location="/Users/JJneid/Desktop/SlashMl/s2t_experiments/api_tests/test_audio_1.mp3" - # when - API_KEY="1bd15e1c161ff6d4db2ea1d661d7468b4fa61ca9" - model_choice="assembly" - result = speect_to_text.upload_audio(file_location,API_KEY, model_choice) - print(result) - # then - # assert result== 'https://api.slashml.com/v1/speech-to-text/upload' - -def test_transcribe(): - import speechtotext - # given: there is a local file - speect_to_text = speechtotext.SpeechToText() - upload_url="https://cdn.assemblyai.com/upload/f973cc7a-45f8-47b9-8ebc-20bd2f63a2bd" - # when - API_KEY="1bd15e1c161ff6d4db2ea1d661d7468b4fa61ca9" - model_choice="assembly" - result = speect_to_text.transcribe(upload_url,API_KEY, model_choice) - - print(result) - -def test_status(): - import speechtotext - # given: there is a local file - speect_to_text = speechtotext.SpeechToText() - upload_url="https://cdn.assemblyai.com/upload/28313e17-9a51-43cd-a29f-68dedd772f83" - # when - job_id= "r4ff9gd76c-530e-4e27-bed4-ce12b63b26b0" - API_KEY="1bd15e1c161ff6d4db2ea1d661d7468b4fa61ca9" - model_choice="assembly" - result = speect_to_text.status(job_id,API_KEY, model_choice=model_choice) - - print(json.loads(result)["text"]) - -test_upload() -#test_transcribe() -#test_status() -# API_KEY="1bd15e1c161ff6d4db2ea1d661d7468b4fa61ca9" -# token="Token {api}".format(api=API_KEY) -# print(token) - -# headers = {'authorization': token} -# print(headers) \ No newline at end of file diff --git a/src/LICENSE.txt b/src/LICENSE.txt new file mode 100644 index 0000000..9b50105 --- /dev/null +++ b/src/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 SlashML + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/requirements.txt b/src/requirements.txt new file mode 100644 index 0000000..d15ce5a --- /dev/null +++ b/src/requirements.txt @@ -0,0 +1 @@ +requests==2.28.1 diff --git a/src/speechtotext.py b/src/speechtotext.py new file mode 100644 index 0000000..481dbc7 --- /dev/null +++ b/src/speechtotext.py @@ -0,0 +1,85 @@ +import requests +import os +from pathlib import Path +import json + +class SpeechToText: + + SLASHML_BASE_URL = 'https://api.slashml.com/speech-to-text/v1' + SLASHML_UPLOAD_URL = SLASHML_BASE_URL+'/upload/' + SLASHML_TRANSCRIPT_URL = SLASHML_BASE_URL+'/transcribe/' + SLASHML_STATUS_URL = SLASHML_BASE_URL+'/transcription' + SLASHML_TRANSCRIPT_STATUS_URL = lambda self,id: f"{SpeechToText.SLASHML_STATUS_URL}/{id}/" + + HEADERS:dict = {} + ## add the api key to sys path envs + def __init__(self,API_KEY: str = None): + self.API_KEY=None + if API_KEY: + token="Token {0}".format(API_KEY) + self.HEADERS = {'authorization': token} + # print("Auth with "+API_KEY+"\nMake sure this matches your API Key generated in the dashboard settings") + elif os.environ.get('SLASHML_API_KEY'): + key_env = os.environ.get('SLASHML_API_KEY') + token="Token {0}".format(key_env) + self.HEADERS = {'authorization': token} + # print("Auth with environment variable SLASHML_API_KEY") + else: + self.HEADERS=None + print("No Auth, there are certain limites to the usage") + + def upload_audio(self, file_location:str,header=None): + headers = self.HEADERS + files=[ + ('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg')) + ] + response = requests.post(self.SLASHML_UPLOAD_URL, + headers=headers,files=files) + return response.json()["upload_url"] + + def transcribe(self,upload_url:str, service_provider: str,header=None ): + + transcript_request = {'audio_url': upload_url} + headers = self.HEADERS + payload = { + "uploaded_audio_url": upload_url, + "service_provider": service_provider + } + response = requests.post(self.SLASHML_TRANSCRIPT_URL, headers=headers, data=payload) + # Check the status code of the response + if response.status_code == 200: + return response.json()["id"] + + elif response.status_code == 429: + return "THROTTLED" + + elif response.status_code == 404: + return "NOT FOUND" + + elif response.status_code == 500: + return "SERVER ERROR" + else: + return "UNKNOWN ERROR" + + def status(self,job_id:str, service_provider: str ,header=None): + headers = self.HEADERS + payload = { + "service_provider": service_provider + } + + response = requests.get(self.SLASHML_TRANSCRIPT_STATUS_URL(job_id) , headers=headers, data=payload) + + # Check the status code of the response + if response.status_code == 200: + return response.json()["transcription_data"]["transcription"] + + elif response.status_code == 429: + return "THROTTLED" + + elif response.status_code == 404: + return "NOT FOUND" + + elif response.status_code == 500: + return "SERVER ERROR" + else: + return "UNKNOWN ERROR" \ No newline at end of file diff --git a/src/test_speechtotext_1.py b/src/test_speechtotext_1.py new file mode 100644 index 0000000..65d65a2 --- /dev/null +++ b/src/test_speechtotext_1.py @@ -0,0 +1,21 @@ +import speechtotext +import os + +#API KEY (optional) + +# set environment path +os.environ["SLASHML_API_KEY"] = "0d91bfede9c5c9de6ff1d5610ef71c3b6d5be9ee" +# Initialize SlashML +speect_to_text = speechtotext.SpeechToText() +# optional local file to upload, if not an accessible url +file_location="/Users/JJneid/Desktop/SlashMl/Benchmarking/podcast1/podcast1_long_trim.mp3" +# If your audio files aren't accessible via a URL already, you can upload your audio file using this API +upload_url= speect_to_text.upload_audio(file_location) +# choose your service provider: "asembly", "aws", "whisper" +service_provider="aws" +# transcribe +transcribe_id= speect_to_text.transcribe(upload_url,service_provider) +print(transcribe_id) + +status=speect_to_text.status(transcribe_id,service_provider=service_provider) +print(status) \ No newline at end of file From 58036c12561bd9fa21d87e086ec98d3fcd463132 Mon Sep 17 00:00:00 2001 From: JJneid Date: Tue, 27 Dec 2022 19:57:12 -0500 Subject: [PATCH 2/4] speech to text with license --- LICENSE.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9b50105 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 SlashML + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From af508821de9b91c983e6abae8165d69cca4904a6 Mon Sep 17 00:00:00 2001 From: JJneid Date: Tue, 27 Dec 2022 20:14:43 -0500 Subject: [PATCH 3/4] changing name of import --- src/{speechtotext.py => slashml.py} | 0 src/test_speechtotext_1.py | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/{speechtotext.py => slashml.py} (100%) diff --git a/src/speechtotext.py b/src/slashml.py similarity index 100% rename from src/speechtotext.py rename to src/slashml.py diff --git a/src/test_speechtotext_1.py b/src/test_speechtotext_1.py index 65d65a2..fb483f3 100644 --- a/src/test_speechtotext_1.py +++ b/src/test_speechtotext_1.py @@ -1,4 +1,4 @@ -import speechtotext +import slashml import os #API KEY (optional) @@ -6,7 +6,7 @@ # set environment path os.environ["SLASHML_API_KEY"] = "0d91bfede9c5c9de6ff1d5610ef71c3b6d5be9ee" # Initialize SlashML -speect_to_text = speechtotext.SpeechToText() +speect_to_text = slashml.SpeechToText() # optional local file to upload, if not an accessible url file_location="/Users/JJneid/Desktop/SlashMl/Benchmarking/podcast1/podcast1_long_trim.mp3" # If your audio files aren't accessible via a URL already, you can upload your audio file using this API From a25a1cc7d10869d0e625ad21605d1c7de2b71a56 Mon Sep 17 00:00:00 2001 From: JJneid Date: Tue, 27 Dec 2022 21:07:21 -0500 Subject: [PATCH 4/4] readme continous update --- README.md | 86 +++++++++++++++++--------------------- src/test_speechtotext_1.py | 3 +- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 49da84b..5cb926b 100644 --- a/README.md +++ b/README.md @@ -1,74 +1,66 @@ -# SLASHML Python client +# SlashML Python client +[SlashML](https://www.slashml.com/) +# Introduction +## Overview +This is a Python client (SDK) for SlashML. It allows the user to use the apps available and active in [SlashML-Dashboard](https://www.slashml.com/dashboard). +The apps can be together in the same code. For example, if the user wants to transcribe an audio file and get a summary, they can call speechtotext followed by summarization. -This is a Python client for SLASHML. It lets you run transcription jobs from your Python code or Jupyter notebook. Do a transcription job with three lines of code -``` -import speechtotext +State-of-the-art AI models from several service providers are available. At SlashML, we also do the benchmarking on these models for the user. This will give them an idea of the best service provider for their application. For the full list of the available models thru SlashML, click [here](##availlable-service-providers) -speect_to_text = speechtotext.SpeechToText() -transcribe_id= speect_to_text.transcribe(audio_url,service_provider="aws") -status=speect_to_text.status(transcribe_id,service_provider=service_provider) -``` -There is a daily limit (throttling) on the number of calls the user performs, transcription jobs can be done without specifying a token (API key). If the user intends on using the service more frequently, it is recommended to generate an token or API key from the dashboard @ [Slashml.com](https://www.slashml.com/). -Grab your token from [https://www.slashml.com/dashboard] (>settings> new api key) and authenticate by setting it as an environment variable (or when you initialize the service, see examples): +to lets you run transcription jobs from your Python code or Jupyter notebook. The transcription can be done with three lines of code ``` -export SLASHML_API_KEY=[token] -``` -or including it in your code as follows: -``` -import speechtotext -API_KEY="your_api_key" -speect_to_text = speechtotext.SpeechToText(API_KEY) +import slashml + +speect_to_text = slashml.SpeechToText() transcribe_id= speect_to_text.transcribe(audio_url,service_provider="aws") status=speect_to_text.status(transcribe_id,service_provider=service_provider) ``` --- update from this part, include examples, sign up, token, service providers, type of servies, benchmarking, link to pricing, Tutorial examples/examples +## Set up and usage +There is a daily limit (throttling) on the number of calls the user performs, the code runs without specifying a token (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 [SlashML-Dashboard](https://www.slashml.com/dashboard). This way, the throttling limit will increase. -SDK for SlashML documentation: -- methods: upload_audio, transcribe, status +Sign up and Grab your token from [SlashML-Dashboard](https://www.slashml.com/dashboard)>settings> new api key and authenticate by setting it as an environment variable (or when you initialize the service, see Quickstart tutorial): -Steps to Integrate -1 - (Optional) Upload files where the data points to your audio file +In your terminal ``` -# call the class -speect_to_text = speechtotext.SpeechToText() -file_location="path/to/your/file.mp3" -# when -API_KEY="SLASH_ML_API_KEY" -model_choice="assembly" -result_upload = speect_to_text.upload_audio(file_location,API_KEY, model_choice) -print(result_upload) +export SLASHML_API_KEY=[token] +``` +or including it in your python code as follows: ``` -Save the upload_url. You can use this url link in the rest of the calls. +import os +os.environ["SLASHML_API_KEY"] = "slashml_api_token" -2- Submit your audio file for transcription ``` -upload_url=upload_url # you can skip step 1 and just input the accessible link of your # file) -result_transcribe = speect_to_text.transcribe(upload_url,API_KEY, model_choice) +If the user preferes using the API calls directly, the documentation is available [here](https://www.slashml.com/dashboard). +## Availlable service providers -print(result_transcribe) -``` -Save the id in the response object. +### Speech-to-text +AssemblyAI +AWS +Whisper (OpenAI) -3 - Check the status and get the text result of the transcription -``` -job_id= id -result_status = speect_to_text.status(job_id,API_KEY, model_choice=model_choice) +### Summarization +hugging-face summarization based on Meta... include links +# Quickstart tutorial -### get the full details of the result -print(result_status) -### get the text reulst only -print(json.loads(result)["text"]) -``` +## Introduction + +### Start with initializing the service + +### Specify your service provider + +In this step, benchmarking will help you decide which service provider is the best for you. +For speech-to-text: "assembly", "aws", "whisper" +For summarization: "hugging-face", "openai" et voilà, Next steps: - pip install slashml -- add SLASH_API_KEY to sys path diff --git a/src/test_speechtotext_1.py b/src/test_speechtotext_1.py index fb483f3..ef6e690 100644 --- a/src/test_speechtotext_1.py +++ b/src/test_speechtotext_1.py @@ -4,6 +4,7 @@ #API KEY (optional) # set environment path +import os os.environ["SLASHML_API_KEY"] = "0d91bfede9c5c9de6ff1d5610ef71c3b6d5be9ee" # Initialize SlashML speect_to_text = slashml.SpeechToText() @@ -11,7 +12,7 @@ file_location="/Users/JJneid/Desktop/SlashMl/Benchmarking/podcast1/podcast1_long_trim.mp3" # If your audio files aren't accessible via a URL already, you can upload your audio file using this API upload_url= speect_to_text.upload_audio(file_location) -# choose your service provider: "asembly", "aws", "whisper" +# choose your service provider: "assembly", "aws", "whisper" service_provider="aws" # transcribe transcribe_id= speect_to_text.transcribe(upload_url,service_provider)