Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 41ae3aa

Browse files
authored
Merge pull request #93 from aflorithmic/assume-org-support
Assume org support
2 parents eba76ea + fd9fe5e commit 41ae3aa

File tree

4 files changed

+102
-53
lines changed

4 files changed

+102
-53
lines changed

CHANGELOG.md

Lines changed: 68 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
# Changelog
2-
* Friday 20th May 2022
3-
v0.16.2
2+
3+
- Friday \*\* June 2022
4+
v0.16.2
5+
6+
## Enhancements
7+
8+
- We introduced a new function called `set_assume_org_id` for incoming super organization feature. By using this method, you can assume the id of a child organization as their super organization, and make your calls on behalf of them.
9+
10+
- Friday 20th May 2022
11+
v0.16.1
412

513
## Bug fixing
6-
* We noticed in testing some additional latency caused by our feature flag implementation - so we refactored this to make it much faster. This was mostly visible in our custom voice implementations.
714

15+
- We noticed in testing some additional latency caused by our feature flag implementation - so we refactored this to make it much faster. This was mostly visible in our custom voice implementations.
816

917
### Enhancements
10-
* We added the ability to share audio with other users. It's a magic link feature.
11-
For example
18+
19+
- We added the ability to share audio with other users. It's a magic link feature.
20+
For example
21+
1222
```shell
1323
curl -X POST \
1424
'https://v1.api.audio/mastering' \
@@ -19,19 +29,20 @@ curl -X POST \
1929
"share": true
2030
}'
2131
```
22-
This returns a url - if you goto
23-
24-
https://console-api.audio/share?id=your_id
25-
26-
You'll get a page that you can share with your organisation and via Whatsapp and other social
27-
networks.
2832

29-
* We've updated our [voice library page](https://library.api.audio/voices) to have faster loading and we've added some other improvements in the GET request for voices so you can have a better voice discovery experience. Most of this is backend and performance enhancements.
30-
* Enhanced query parameters for voice discoverability
33+
This returns a url - if you goto
34+
35+
https://console-api.audio/share?id=your_id
36+
37+
You'll get a page that you can share with your organisation and via Whatsapp and other social
38+
networks.
39+
40+
- We've updated our [voice library page](https://library.api.audio/voices) to have faster loading and we've added some other improvements in the GET request for voices so you can have a better voice discovery experience. Most of this is backend and performance enhancements.
41+
- Enhanced query parameters for voice discoverability
3142

3243
`GET https://v1.api.audio/voice?tags=upbeat,storytelling`
3344

34-
Will voices that have both of these tags. We also introduced pagination as well.
45+
Will voices that have both of these tags. We also introduced pagination as well.
3546

3647
**Pagination**
3748
(Not yet available in the SDK)
@@ -45,10 +56,9 @@ E.g.
4556

4657
`GET https://v1.api.audio/voice?limit=10&offset=30`
4758

48-
4959
**Query body in POST /voice**
5060

51-
A `query` JSON is available in POST method.
61+
A `query` JSON is available in POST method.
5262

5363
**Supported operators:**
5464

@@ -58,93 +68,103 @@ A `query` JSON is available in POST method.
5868

5969
```json
6070
{
61-
"query": {
62-
"language": "english",
63-
"provider": "polly"
64-
}
71+
"query": {
72+
"language": "english",
73+
"provider": "polly"
74+
}
6575
}
6676
```
6777

6878
**List specific languages:**
6979

7080
```json
7181
{
72-
"query": {
73-
"language": {
74-
"$is_in": ["english", "spanish", "polish"]
75-
}
82+
"query": {
83+
"language": {
84+
"$is_in": ["english", "spanish", "polish"]
7685
}
86+
}
7787
}
7888
```
7989

8090
**List only private and public_paid tiers:**
8191

8292
```json
8393
{
84-
"query": {
85-
"tier": {
86-
"$ne": "public"
87-
}
94+
"query": {
95+
"tier": {
96+
"$ne": "public"
8897
}
98+
}
8999
}
90100
```
91-
**List spanish voices where priority is less than or equal to 3:**
92101

102+
**List spanish voices where priority is less than or equal to 3:**
93103

94104
```json
95105
{
96-
"query": {
97-
"language": "spanish",
98-
"priority": {"$lte": 3}
99-
}
106+
"query": {
107+
"language": "spanish",
108+
"priority": { "$lte": 3 }
109+
}
100110
}
101111
```
102-
There's a lot you can do with this so we hope this makes your develper experience easier.
112+
113+
There's a lot you can do with this so we hope this makes your develper experience easier.
103114

104115
## New released features
105-
* Enhancements of voices. We've been testing with some users a more natural pauses to our custom voices. We contacted customers affected and some requested to not have this feature enabled please contact us if you want to use the old voices. We do feel that these voices are more natural and our beta testing was positive. These will be available soon under `msnr` voices in our API.
106116

107-
* As a developer user I want to share my audio with my team/bosses/business person so they can try and test the wonders of api.audio. We call this *virality link* and it's available in the console soon.
117+
- Enhancements of voices. We've been testing with some users a more natural pauses to our custom voices. We contacted customers affected and some requested to not have this feature enabled please contact us if you want to use the old voices. We do feel that these voices are more natural and our beta testing was positive. These will be available soon under `msnr` voices in our API.
118+
119+
- As a developer user I want to share my audio with my team/bosses/business person so they can try and test the wonders of api.audio. We call this _virality link_ and it's available in the console soon.
108120

109-
* Friday 13th May 2022
121+
- Friday 13th May 2022
110122

111123
v0.16.0
124+
112125
## Features
113-
* We added new endFormat (for making sure your audio is the correct format for a target audience) this week we added Alexa preset
126+
127+
- We added new endFormat (for making sure your audio is the correct format for a target audience) this week we added Alexa preset
128+
114129
```python
115130
m = apiaudio.Mastering().create(scriptId=GLOBAL_SCRIPT_ID, endFormat="mp3_alexa")
116-
```
117-
In the future we will add other endFormats - please tell us which ones you'd like.
131+
```
118132

119-
* To continue to be able to offer free content to those of you still getting to know API.audio, we have added a watermark to our files.
133+
In the future we will add other endFormats - please tell us which ones you'd like.
120134

135+
- To continue to be able to offer free content to those of you still getting to know API.audio, we have added a watermark to our files.
121136

122137
### Corporate features
123-
* For our corporate plan users we've enabled `sandboxing` this allows you to test safely API requests without using up credits. Please contact your account manager for further details.
124138

139+
- For our corporate plan users we've enabled `sandboxing` this allows you to test safely API requests without using up credits. Please contact your account manager for further details.
125140

126141
## Breaking Changes
127-
* Our feature (pronunciation dictionary) has had some usability enhancements. The biggest change is adding `useDictionary` as a boolean.
128-
Here's an example
142+
143+
- Our feature (pronunciation dictionary) has had some usability enhancements. The biggest change is adding `useDictionary` as a boolean.
144+
Here's an example
129145
```python
130146
scriptText = """Hello I am reading a book in the city of <!location>reading<!> today"""
131147
script = apiaudio.Script.create(scriptText=scriptText)
132148
speech = apiaudio.Speech.create(scriptId=script["scriptId"], voice="Ryan", useDictionary=True)
133149
print(speech)
134150
```
135-
The addition of useDictionary and the change in behaviour is likely to present some breaking changes. We've notified any customers who are affected.
151+
The addition of useDictionary and the change in behaviour is likely to present some breaking changes. We've notified any customers who are affected.
136152

137153
## Bug Fixing
154+
138155
We had some third party downtime with some voices from one provider. We notified them and fixed this issue.
139156

140157
## Maintenance
158+
141159
We have removed old code and streamlined other code using our Mastering engine. This will allow us to add features more easily whilst removing unnecessary complexity.
142160
We also made various performance improvements and work in the background. Although not all of this will be customer facing, these incremental improvements are very important.
143161

144162
## Unreleased
163+
145164
(These are features that aren't added yet, but will be released next week)
146-
* Enhancements of voices. We've been testing with some users a more natural pauses to our custom voices. We contacted customers affected and some requested to not have this feature enabled please contact us if you want to use the old voices. We do feel that these voices are more natural and our beta testing was positive. These will be available soon under `msnr` voices in our API.
147165

148-
* As a developer user I want to share my audio with my team/bosses/business person so they can try and test the wonders of api.audio. We call this *virality link* and it's available in the console soon.
166+
- Enhancements of voices. We've been testing with some users a more natural pauses to our custom voices. We contacted customers affected and some requested to not have this feature enabled please contact us if you want to use the old voices. We do feel that these voices are more natural and our beta testing was positive. These will be available soon under `msnr` voices in our API.
167+
168+
- As a developer user I want to share my audio with my team/bosses/business person so they can try and test the wonders of api.audio. We call this _virality link_ and it's available in the console soon.
149169

150-
* We've been developing the usability of our data capture app for voice cloning (this is available in some plans). You'll see this in the next few weeks.
170+
- We've been developing the usability of our data capture app for voice cloning (this is available in some plans). You'll see this in the next few weeks.

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ export apiaudio_key=<your-key>
187187

188188
If you provide both environment variable and `apiaudio.api_key` authentication, the `apiaudio.api_key` will be used.
189189

190+
### Super Organizations
191+
192+
In order to control a child organization of yours, please use the following method to assume that organization id.
193+
194+
Set your child organization id to `None` to stop assuming an organization.
195+
196+
```python
197+
import apiaudio
198+
199+
apiaudio.set_assume_org_id('child_org_id')
200+
201+
# Stop using
202+
apiaudio.set_assume_org_id(None)
203+
```
204+
190205
### Resource Usage <a name = "resource"> </a>
191206

192207
There are two approaches to use the resources.
@@ -303,7 +318,7 @@ Speech methods are:
303318
- `version` (string) - The version of the script to be produced. Default is "".
304319
- `voice` (string) - Voice name. See the list of available voices using [Voice resource](#voice). Default voice is "Joanna".
305320
- `speed` (string) - Voice speed. Default speed is 100.
306-
- `effect` (string) - Put a funny effect in your voice. You can try the following ones: `dark_father`, `chewie`, `88b`, `2r2d`,
321+
- `effect` (string) - Put a funny effect in your voice. You can try the following ones: `dark_father`, `chewie`, `88b`, `2r2d`,
307322
- `silencePadding` (integer) - Add a silence padding to your speech tracks (in milliseconds). Default is 0 (no padding)
308323
- `audience` (dict) - Specify the values of parameters in your script. For instance, if in the script resource you have `scriptText="Hello {{name}} {{lastname}}, welcome to {{location}}"`, the audience should be: `{"name": "Elon", "lastname": "Musk", "location": "Istanbul"}`. If not provided, the fallback track will be created.
309324
- `sync` (boolean) - Allow sync or async speech creation. Default is `True`. If `sync=False`, speech create call will return a success message when the speech creation is triggered. To retrieve the files, check `Speech.retrieve()` method.
@@ -457,7 +472,7 @@ Mastering allows you to create and retrieve a mastered audio file of your script
457472

458473
Mastering methods are:
459474

460-
- `create()` Create a mastered version of your script and choose the audio format.
475+
- `create()` Create a mastered version of your script and choose the audio format.
461476

462477
- Parameters:
463478

apiaudio/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
# Configuration variables
55

6-
sdk_version = "0.16.0"
6+
sdk_version = "0.16.2"
77

88
api_key = None
9-
client_id = None
9+
assume_org_id = None
1010
api_base = "https://v1.api.audio"
1111
upload_api_base = "https://file.api.audio" # not implemented yet.
1212

@@ -21,10 +21,12 @@
2121

2222
# API resources
2323
from apiaudio.api_resources import *
24+
from apiaudio.api_request import APIRequest
2425

2526
# logging
2627
from apiaudio.logging import SDKLogger
2728

29+
2830
_logger = SDKLogger()
2931
_version_warning_issued = False
3032

@@ -35,3 +37,8 @@ def set_logger_level(level):
3537
assert level in available_levels, f"Available logging levels: {available_levels}"
3638

3739
_logger = SDKLogger(level=level)
40+
41+
42+
# super org assume mechanism
43+
def set_assume_org_id(org_id):
44+
return APIRequest.set_assume_org_id(org_id)

apiaudio/api_request.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,17 @@ def _api_key_checker(api_key=None):
3030
apiaudio.api_key = api_key
3131
return
3232

33+
def set_assume_org_id(org_id):
34+
apiaudio.assume_org_id = org_id
35+
3336
@classmethod
3437
def _build_header(cls):
3538
cls._api_key_checker(apiaudio.api_key)
36-
return {"x-api-key": apiaudio.api_key, "x-python-sdk-version": sdk_version}
39+
return {
40+
"x-api-key": apiaudio.api_key,
41+
"x-python-sdk-version": sdk_version,
42+
"x-assume-org": apiaudio.assume_org_id,
43+
}
3744

3845
@classmethod
3946
def _post_request(cls, json, url=None):

0 commit comments

Comments
 (0)