Skip to content

Conversation

@eff-kay
Copy link
Contributor

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

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

@@ -1,2 +0,0 @@
.DS_Store
services.py
Copy link
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

@@ -0,0 +1,75 @@
import requests
Copy link
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.


return "UNKNOWN ERROR"

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

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

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
Copy link
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

# print("Auth with environment variable SLASHML_API_KEY")
else:
self.HEADERS=None
print("No Auth, there are certain limites to the usage")
Copy link
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
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

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
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

files=[
('audio',('test_audio.mp3',open(file_location,'rb'),'audio/mpeg'))
]
response = requests.post(self.SLASHML_UPLOAD_URL,
Copy link
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.

]
response = requests.post(self.SLASHML_UPLOAD_URL,
headers=headers,files=files)
return response.json()["upload_url"]
Copy link
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.

transcript_request = {'audio_url': upload_url}
headers = self.HEADERS
payload = {
"uploaded_audio_url": upload_url,
Copy link
Contributor Author

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"]
Copy link
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.

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

# 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
Contributor Author

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
Copy link
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
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
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.

# 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
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.

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
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

```
or including it in your code as follows:
```
import speechtotext
Copy link
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

3 participants