most-client 1.0.13__py3-none-any.whl → 1.0.15__py3-none-any.whl

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.
most/api.py CHANGED
@@ -2,7 +2,7 @@ from typing import List, Dict
2
2
  import json5
3
3
  import requests
4
4
  from adaptix import Retort
5
- from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData, is_valid_id
5
+ from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData, is_valid_id, DialogResult
6
6
  from pathlib import Path
7
7
 
8
8
 
@@ -205,6 +205,16 @@ class MostClient(object):
205
205
  resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/text")
206
206
  return self.retort.load(resp.json(), Result)
207
207
 
208
+ def fetch_dialog(self, audio_id) -> DialogResult:
209
+ if not is_valid_id(self.model_id):
210
+ raise RuntimeError("Please choose valid model to apply. [try list_models()]")
211
+
212
+ if not is_valid_id(audio_id):
213
+ raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
214
+
215
+ resp = self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
216
+ return self.retort.load(resp.json(), DialogResult)
217
+
208
218
  def export(self, audio_ids: List[str]) -> str:
209
219
  if not is_valid_id(self.model_id):
210
220
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
most/async_api.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from typing import List, Dict
2
2
  import json5
3
3
  from adaptix import Retort
4
- from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData, is_valid_id
4
+ from most.types import Audio, Result, Script, JobStatus, Text, StoredAudioData, is_valid_id, DialogResult
5
5
  from pathlib import Path
6
6
  import httpx
7
7
 
@@ -214,6 +214,16 @@ class AsyncMostClient(object):
214
214
  resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/text")
215
215
  return self.retort.load(resp.json(), Result)
216
216
 
217
+ async def fetch_dialog(self, audio_id) -> DialogResult:
218
+ if not is_valid_id(self.model_id):
219
+ raise RuntimeError("Please choose valid model to apply. [try list_models()]")
220
+
221
+ if not is_valid_id(audio_id):
222
+ raise RuntimeError("Please use valid audio_id. [try audio.id from list_audios()]")
223
+
224
+ resp = await self.get(f"https://api.the-most.ai/api/external/{self.client_id}/audio/{audio_id}/model/{self.model_id}/dialog")
225
+ return self.retort.load(resp.json(), DialogResult)
226
+
217
227
  async def export(self, audio_ids: List[str]) -> str:
218
228
  if not is_valid_id(self.model_id):
219
229
  raise RuntimeError("Please choose valid model to apply. [try list_models()]")
most/types.py CHANGED
@@ -1,6 +1,5 @@
1
+ import re
1
2
  from dataclasses import dataclass
2
-
3
- from bson import ObjectId
4
3
  from dataclasses_json import dataclass_json, DataClassJsonMixin
5
4
  from typing import Optional, List, Literal, Dict
6
5
 
@@ -77,6 +76,49 @@ class Result(DataClassJsonMixin):
77
76
  for column_result in self.results])
78
77
 
79
78
 
79
+ @dataclass_json
80
+ @dataclass
81
+ class DialogSegment(DataClassJsonMixin):
82
+ start_time_ms: int
83
+ end_time_ms: int
84
+ text: str
85
+ speaker: str
86
+ emotion: Optional[str] = None
87
+ intensity: Optional[float] = None
88
+
89
+ def to_text(self):
90
+ if self.emotion is None:
91
+ return f'{self.speaker}: {self.text}\n'
92
+ else:
93
+ return f'{self.speaker}: <emotion name="{self.emotion}" intensity="{self.intensity}">{self.text}</emotion>\n'
94
+
95
+
96
+ @dataclass_json
97
+ @dataclass
98
+ class Dialog(DataClassJsonMixin):
99
+ segments: List[DialogSegment]
100
+
101
+ def to_text(self):
102
+ return ''.join([segment.to_text()
103
+ for segment in self.segments])
104
+
105
+
106
+ @dataclass_json
107
+ @dataclass
108
+ class DialogResult(DataClassJsonMixin):
109
+ id: str
110
+ dialog: Optional[Dialog]
111
+ url: Optional[str]
112
+ results: Optional[List[ColumnResult]]
113
+
114
+
115
+ def is_valid_objectid(oid: str) -> bool:
116
+ """
117
+ Check if a given string is a valid MongoDB ObjectId (24-character hex).
118
+ """
119
+ return bool(re.fullmatch(r"^[0-9a-fA-F]{24}$", oid))
120
+
121
+
80
122
  def is_valid_id(smth_id: Optional[str]) -> bool:
81
123
  if smth_id is None:
82
124
  return False
@@ -84,8 +126,4 @@ def is_valid_id(smth_id: Optional[str]) -> bool:
84
126
  if smth_id.startswith("most-"):
85
127
  smth_id = smth_id[5:]
86
128
 
87
- try:
88
- ObjectId(smth_id)
89
- return True
90
- except:
91
- return False
129
+ return is_valid_objectid(smth_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: most-client
3
- Version: 1.0.13
3
+ Version: 1.0.15
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
@@ -26,7 +26,6 @@ Requires-Dist: pytest
26
26
  Requires-Dist: tox
27
27
  Requires-Dist: twine
28
28
  Requires-Dist: httpx
29
- Requires-Dist: bson==0.5.10
30
29
  Dynamic: author
31
30
  Dynamic: author-email
32
31
  Dynamic: classifier
@@ -0,0 +1,9 @@
1
+ most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
+ most/api.py,sha256=xFuvjL45gNHDJyPd9_QG3u7uv75CMi3EWX5m47odd7E,10598
3
+ most/async_api.py,sha256=eB7bF5a_4hDBCn64VXqXIcu0GIlzYdEIkqihh287qEo,11271
4
+ most/types.py,sha256=tZFuRKx6hxnOvpLw5pPe7p3H1mW_cxFkTc2fJTKxHiI,2824
5
+ most_client-1.0.15.dist-info/METADATA,sha256=-PTbL9VVxEatBuS1VB_icOQjvEZjIjg1XAWxSo8leFw,1006
6
+ most_client-1.0.15.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
7
+ most_client-1.0.15.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
8
+ most_client-1.0.15.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
+ most_client-1.0.15.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- most/__init__.py,sha256=62uFFeM_1VVR83K3bTYWK3PEoqnmFCy9aWYerQ6U4Ds,67
2
- most/api.py,sha256=sGChrPUuwBjSdkkJK3BDOh3YYaxe9xAuGS82GcEdQk4,10074
3
- most/async_api.py,sha256=ZiUXdqRBG8yTEBHfuglN1eaBMr29S9ibWWfFM5EP61w,10735
4
- most/types.py,sha256=nSYmVm27y9py_HG6a7oKSObDRHCymmTYo-x5bYhKqug,1844
5
- most_client-1.0.13.dist-info/METADATA,sha256=KsD6Q75Q2h5mt2wWENoNB0W4QYdbtAVi5q5M0hVdVjY,1034
6
- most_client-1.0.13.dist-info/WHEEL,sha256=nn6H5-ilmfVryoAQl3ZQ2l8SH5imPWFpm1A5FgEuFV4,91
7
- most_client-1.0.13.dist-info/top_level.txt,sha256=2g5fk02LKkM1hV3pVVti_LQ60TToLBcR2zQ3JEKGVk8,5
8
- most_client-1.0.13.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
9
- most_client-1.0.13.dist-info/RECORD,,