most-client 1.0.16__tar.gz → 1.0.18__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: most-client
3
- Version: 1.0.16
3
+ Version: 1.0.18
4
4
  Summary: Most AI API for https://the-most.ai
5
5
  Home-page: https://github.com/the-most-ai/most-client
6
6
  Author: George Kasparyants
@@ -1,7 +1,8 @@
1
1
  import io
2
2
  import os
3
+ import uuid
3
4
  from pathlib import Path
4
- from typing import Dict, List
5
+ from typing import Dict, List, Optional
5
6
 
6
7
  import json5
7
8
  import requests
@@ -145,12 +146,15 @@ class MostClient(object):
145
146
  files={"audio_file": f})
146
147
  return self.retort.load(resp.json(), Audio)
147
148
 
148
- def upload_audio_segment(self, audio: AudioSegment) -> Audio:
149
+ def upload_audio_segment(self, audio: AudioSegment,
150
+ audio_name: Optional[str] = None) -> Audio:
149
151
  f = io.BytesIO()
150
152
  audio.export(f, format="mp3")
151
153
  f.seek(0)
154
+ if audio_name is None:
155
+ audio_name = uuid.uuid4().hex + ".mp3"
152
156
  resp = self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload",
153
- files={"audio_file": f})
157
+ files={"audio_file": (audio_name, f, 'audio/mp3')})
154
158
  return self.retort.load(resp.json(), Audio)
155
159
 
156
160
  def upload_audio_url(self, audio_url) -> Audio:
@@ -237,12 +241,19 @@ class MostClient(object):
237
241
  resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
238
242
  return self.retort.load(resp.json(), DialogResult)
239
243
 
240
- def export(self, audio_ids: List[str]) -> str:
244
+ def export(self, audio_ids: List[str],
245
+ aggregated_by: Optional[str] = None,
246
+ aggregation_title: Optional[str] = None) -> str:
247
+ if aggregation_title is None:
248
+ aggregation_title = aggregated_by
249
+
241
250
  if not is_valid_id(self.model_id):
242
251
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
243
252
 
244
253
  resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/export",
245
- params={'audio_ids': ','.join(audio_ids)})
254
+ params={'audio_ids': ','.join(audio_ids),
255
+ 'aggregated_by': aggregated_by,
256
+ 'aggregation_title': aggregation_title})
246
257
  return resp.url
247
258
 
248
259
  def store_info(self,
@@ -1,7 +1,8 @@
1
1
  import io
2
2
  import os
3
+ import uuid
3
4
  from pathlib import Path
4
- from typing import Dict, List
5
+ from typing import Dict, List, Optional
5
6
 
6
7
  import httpx
7
8
  import json5
@@ -149,12 +150,15 @@ class AsyncMostClient(object):
149
150
  files={"audio_file": f})
150
151
  return self.retort.load(resp.json(), Audio)
151
152
 
152
- async def upload_audio_segment(self, audio: AudioSegment) -> Audio:
153
+ async def upload_audio_segment(self, audio: AudioSegment,
154
+ audio_name: Optional[str] = None) -> Audio:
153
155
  f = io.BytesIO()
154
156
  audio.export(f, format="mp3")
155
157
  f.seek(0)
158
+ if audio_name is None:
159
+ audio_name = uuid.uuid4().hex + ".mp3"
156
160
  resp = await self.post(f"https://api.the-most.ai/api/external/{self.client_id}/upload",
157
- files={"audio_file": f})
161
+ files={"audio_file": (audio_name, f, 'audio/mp3')})
158
162
  return self.retort.load(resp.json(), Audio)
159
163
 
160
164
  async def upload_text(self, text: str) -> Text:
@@ -246,12 +250,19 @@ class AsyncMostClient(object):
246
250
  resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
247
251
  return self.retort.load(resp.json(), DialogResult)
248
252
 
249
- async def export(self, audio_ids: List[str]) -> str:
253
+ async def export(self, audio_ids: List[str],
254
+ aggregated_by: Optional[str] = None,
255
+ aggregation_title: Optional[str] = None) -> str:
256
+ if aggregation_title is None:
257
+ aggregation_title = aggregated_by
258
+
250
259
  if not is_valid_id(self.model_id):
251
260
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
252
261
 
253
262
  resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/model/{self.model_id}/export",
254
- params={'audio_ids': ','.join(audio_ids)})
263
+ params={'audio_ids': ','.join(audio_ids),
264
+ "aggregated_by": aggregated_by,
265
+ "aggregation_title": aggregation_title})
255
266
  return resp.next_request.url
256
267
 
257
268
  async def store_info(self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: most-client
3
- Version: 1.0.16
3
+ Version: 1.0.18
4
4
  Summary: Most AI API for https://the-most.ai
5
5
  Home-page: https://github.com/the-most-ai/most-client
6
6
  Author: George Kasparyants
@@ -8,7 +8,7 @@ with open('requirements.txt', 'r') as f:
8
8
 
9
9
  setup(
10
10
  name='most-client',
11
- version='1.0.16',
11
+ version='1.0.18',
12
12
  python_requires=f'>=3.6',
13
13
  description='Most AI API for https://the-most.ai',
14
14
  url='https://github.com/the-most-ai/most-client',
File without changes
File without changes
File without changes
File without changes