Skip to content

Commit 85578dc

Browse files
committed
add audiotranscription to python SDK
1 parent 297efb8 commit 85578dc

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

README.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,22 @@ __ https://docs.scaleapi.com/#create-data-collection-task
135135
fields={ 'hiring_page': 'Hiring Page URL' },
136136
)
137137
138+
Create audiotranscription task
139+
==============================
140+
141+
Check `this`__ for further information.
142+
143+
__ https://docs.scaleapi.com/#create-audio-transcription-task
144+
145+
.. code-block:: python
146+
147+
task = client.create_audiotranscription_task(
148+
callback_url='http://www.example.com/callback',
149+
attachment_type='audio',
150+
attachment='https://storage.googleapis.com/deepmind-media/pixie/knowing-what-to-say/second-list/speaker-3.wav',
151+
verbatim=False
152+
)
153+
138154
Retrieve task
139155
=============
140156

scaleapi/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
'fields', 'choices'},
1515
'annotation': {'attachment', 'attachment_type', 'instruction',
1616
'objects_to_annotate', 'with_labels', 'examples'},
17-
'datacollection': {'attachment', 'attachment_type', 'fields'}}
17+
'datacollection': {'attachment', 'attachment_type', 'fields'},
18+
'audiotranscription': {'attachment', 'attachment_type', 'verbatim'}}
1819
SCALE_ENDPOINT = 'https://api.scaleapi.com/v1/'
1920
DEFAULT_LIMIT = 100
2021
DEFAULT_OFFSET = 0
@@ -149,3 +150,8 @@ def create_datacollection_task(self, **kwargs):
149150
validate_payload('datacollection', kwargs)
150151
taskdata = self._postrequest('task/datacollection', payload=kwargs)
151152
return Task(taskdata, self)
153+
154+
def create_audiotranscription_task(self, **kwargs):
155+
validate_payload('audiotranscription', kwargs)
156+
taskdata = self._postrequest('task/audiotranscription', payload=kwargs)
157+
return Task(taskdata, self)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
setup(
33
name = 'scaleapi',
44
packages = ['scaleapi'],
5-
version = '0.1.5',
5+
version = '0.1.6',
66
description = 'The official Python client library for the Scale API, the API for human labor.',
77
author = 'Calvin Huang',
88
author_email = 'c@lvin.me',
99
url = 'https://github.com/scaleapi/scaleapi-python-client',
1010
download_url = 'https://github.com/scaleapi/scaleapi-python-client/tarball/0.1.2',
11-
keywords = ['scale', 'scaleapi', 'humans', 'tasks', 'categorization', 'transcription', 'annotation', 'comparison', 'data collection', 'phone call'],
11+
keywords = ['scale', 'scaleapi', 'humans', 'tasks', 'categorization', 'transcription', 'annotation', 'comparison', 'data collection', 'phone call', 'audio transcription'],
1212
install_requires = ['requests', 'enum34'],
1313
classifiers = ['Programming Language :: Python :: 2.7',
1414
'Programming Language :: Python :: 3.5',

tests/test_client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,29 @@ def test_datacollection_fail():
134134
attachment_type='website')
135135

136136

137+
def test_audiotranscription_ok():
138+
task = client.create_audiotranscription_task(
139+
callback_url='http://www.example.com/callback',
140+
attachment_type='audio',
141+
attachment='https://storage.googleapis.com/deepmind-media/pixie/knowing-what-to-say/second-list/speaker-3.wav',
142+
verbatim=False
143+
)
144+
145+
146+
def test_audiotranscription_fail():
147+
with pytest.raises(scaleapi.ScaleInvalidRequest):
148+
client.create_audiotranscription_task(
149+
callback_url='http://www.example.com/callback',
150+
attachment_type='audio')
151+
152+
153+
def test_audiotranscription_fail2():
154+
with pytest.raises(scaleapi.ScaleInvalidRequest):
155+
client.create_audiotranscription_task(
156+
callback_url='http://www.example.com/callback',
157+
attachment='some_non_url')
158+
159+
137160
def test_cancel():
138161
task = make_a_task()
139162
# raises a scaleexception, because test tasks complete instantly

0 commit comments

Comments
 (0)