Skip to content

Update sdk#13

Open
eff-kay wants to merge 5 commits intomainfrom
update_sdk
Open

Update sdk#13
eff-kay wants to merge 5 commits intomainfrom
update_sdk

Conversation

@eff-kay
Copy link
Copy Markdown
Contributor

@eff-kay eff-kay commented Dec 6, 2022

fixes #7 , #8 , #11 , #10

Comment thread .gitignore
@@ -1,2 +0,0 @@
.DS_Store
services.py
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a .gitignore

Comment thread src/speechtotext.py
@@ -0,0 +1,75 @@
import requests
Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/speechtotext.py

return "UNKNOWN ERROR"

# return response.json()["transcription_data"]["transcription"]
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Comment thread src/speechtotext.py
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")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Comment thread src/speechtotext.py
HEADERS:dict = {}
## add the api key to sys path envs
def __init__(self,API_KEY: str = None):
self.API_KEY=None
Copy link
Copy Markdown
Contributor Author

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

Comment thread src/speechtotext.py
# print("Auth with environment variable SLASHML_API_KEY")
else:
self.HEADERS=None
print("No Auth, there are certain limites to the usage")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

limits typo

Copy link
Copy Markdown
Contributor Author

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

Comment thread src/speechtotext.py
def upload_audio(self, file_location:str,header=None):
headers = self.HEADERS
files=[
('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg'))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improve the formatting

Comment thread src/speechtotext.py
files=[
('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg'))
]
response = requests.post(self.SLASHML_UPLOAD_URL,
Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/speechtotext.py
]
response = requests.post(self.SLASHML_UPLOAD_URL,
headers=headers,files=files)
return response.json()["upload_url"]
Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/speechtotext.py
transcript_request = {'audio_url': upload_url}
headers = self.HEADERS
payload = {
"uploaded_audio_url": upload_url,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improve formatting.

Comment thread src/speechtotext.py
"service_provider": service_provider
}
response = requests.post(self.SLASHML_TRANSCRIPT_URL, headers=headers, data=payload)
return response.json()["id"]
Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/speechtotext.py
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:
Copy link
Copy Markdown
Contributor Author

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.

Comment thread src/speechtotext.py
# 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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comments

Comment thread src/status_test.py
@@ -0,0 +1,24 @@
import speechtotext
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown
Contributor Author

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"
Copy link
Copy Markdown
Contributor Author

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.

Comment thread README.md
# 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
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread README.md

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)
Copy link
Copy Markdown
Contributor Author

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

Comment thread README.md
```
or including it in your code as follows:
```
import speechtotext
Copy link
Copy Markdown
Contributor Author

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

@JJneid JJneid mentioned this pull request Dec 28, 2022
@JJneid JJneid closed this Dec 28, 2022
@JJneid JJneid reopened this Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rename SDK_V1 to src

2 participants