-
Notifications
You must be signed in to change notification settings - Fork 1
Update sdk #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update sdk #13
Conversation
| @@ -1,2 +0,0 @@ | |||
| .DS_Store | |||
| services.py | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a .gitignore
| @@ -0,0 +1,75 @@ | |||
| import requests | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the *.pyc file above.
|
|
||
| return "UNKNOWN ERROR" | ||
|
|
||
| # return response.json()["transcription_data"]["transcription"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comments
| 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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comments
| HEADERS:dict = {} | ||
| ## add the api key to sys path envs | ||
| def __init__(self,API_KEY: str = None): | ||
| self.API_KEY=None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable is not required
| # print("Auth with environment variable SLASHML_API_KEY") | ||
| else: | ||
| self.HEADERS=None | ||
| print("No Auth, there are certain limites to the usage") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limits typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
point them to the relevant webpage where they can get the API token
| def upload_audio(self, file_location:str,header=None): | ||
| headers = self.HEADERS | ||
| files=[ | ||
| ('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve the formatting
| files=[ | ||
| ('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg')) | ||
| ] | ||
| response = requests.post(self.SLASHML_UPLOAD_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the response is an error.
| ] | ||
| response = requests.post(self.SLASHML_UPLOAD_URL, | ||
| headers=headers,files=files) | ||
| return response.json()["upload_url"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the json() does not contain upload_url.
| transcript_request = {'audio_url': upload_url} | ||
| headers = self.HEADERS | ||
| payload = { | ||
| "uploaded_audio_url": upload_url, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improve formatting.
| "service_provider": service_provider | ||
| } | ||
| response = requests.post(self.SLASHML_TRANSCRIPT_URL, headers=headers, data=payload) | ||
| return response.json()["id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as upload function, what if the id is not in json.
| 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so we need a uniform pattern for how to deal with 400s, 500s. Either the same should be done for the other endpoints as well, or they should not be done for the other endpoints.
| # return response.json()["transcription_data"]["transcription"] | ||
|
|
||
|
|
||
| #### chgeck the code of the reponse, ifit is not 200, print back the error. No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments
| @@ -0,0 +1,24 @@ | |||
| import speechtotext | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this file altogether.
| @@ -0,0 +1,21 @@ | |||
| import speechtotext | |||
| import os | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either convert this file to proper test_cases, or remove this file altogether. If the purpose is to show how to use the API, move this file to a samples folder and create a sample application in there, along with the relevant file.
| # Initialize SlashML | ||
| speect_to_text = speechtotext.SpeechToText() | ||
| # optional local file to upload, if not an accessible url | ||
| file_location="/Users/JJneid/Desktop/SlashMl/s2t_experiments/api_tests/2test_audio.mp3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this location is specific to your computer, the file will not work on someone else's computer.
| # SLASHML Python client | ||
|
|
||
| to be updated to guide users | ||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 | |
| This is a Python client for [SlashML](https://slashml.com). It lets you call machine learning APIs from your Python code or Jupyter notebook. | |
| Following is an example of how to do Transcription with 3 lines of code. |
| 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 was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait for status to be COMPLETED
| ``` | ||
| or including it in your code as follows: | ||
| ``` | ||
| import speechtotext |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this code is outdated
fixes #7 , #8 , #11 , #10