behavioralsignals 0.1.0__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.
@@ -0,0 +1,7 @@
1
+ from .client import Client
2
+ from .models import StreamingOptions
3
+ from .deepfakes import Deepfakes
4
+ from .behavioral import Behavioral
5
+
6
+
7
+ __all__ = ["Client", "Behavioral", "Deepfakes", "StreamingOptions"]
@@ -0,0 +1,79 @@
1
+ from typing import Optional
2
+
3
+ import grpc
4
+ import requests
5
+
6
+ from .models import APIError
7
+ from .configuration import Configuration
8
+
9
+
10
+ class BaseClient:
11
+ def __init__(self, cid: str, api_key: str):
12
+ self.config = Configuration(cid=cid, api_key=api_key)
13
+ self.session = requests.Session()
14
+ self._authenticate()
15
+
16
+ def _get_default_headers(self):
17
+ headers = {
18
+ "accept": "application/json",
19
+ "X-Auth-Token": self.config.api_key,
20
+ }
21
+ return headers
22
+
23
+ def _handle_response(self, response: requests.Response) -> dict:
24
+ if response.status_code != 200:
25
+ try:
26
+ error = APIError(**response.json())
27
+ raise Exception(f"API Error {error.code}: {error.message}")
28
+ except ValueError:
29
+ raise Exception(f"HTTP {response.status_code}: {response.text}")
30
+ return response.json()
31
+
32
+ def _authenticate(self):
33
+ headers = self._get_default_headers()
34
+ headers["X-Auth-Client"] = self.config.cid
35
+ response = self._send_request(path="auth", method="GET", headers=headers)
36
+ return response
37
+
38
+ def _send_request(
39
+ self,
40
+ path: str,
41
+ method: str = "GET",
42
+ data: Optional[dict] = None,
43
+ headers: Optional[dict] = None,
44
+ files: Optional[dict] = None,
45
+ ):
46
+ url = self.config.api_url + "/" + path
47
+ if headers is None:
48
+ headers = self._get_default_headers()
49
+
50
+ if method == "GET":
51
+ response = self.session.get(
52
+ url, headers=headers, params=data, timeout=self.config.timeout
53
+ )
54
+ elif method == "POST":
55
+ response = self.session.post(
56
+ url, headers=headers, data=data, files=files, timeout=self.config.timeout
57
+ )
58
+ else:
59
+ raise ValueError(f"Unsupported method: {method}")
60
+
61
+ return self._handle_response(response)
62
+
63
+ def close(self):
64
+ """Close the session."""
65
+ self.session.close()
66
+
67
+ def __enter__(self):
68
+ return self
69
+
70
+ def __exit__(self, exc_type, exc_value, traceback):
71
+ self.close()
72
+
73
+ def _get_channel_context(self):
74
+ """Returns the channel context for gRPC connections."""
75
+ if self.config.use_ssl:
76
+ credentials = grpc.ssl_channel_credentials()
77
+ return grpc.secure_channel(self.config.streaming_api_url, credentials=credentials)
78
+ else:
79
+ return grpc.insecure_channel(self.config.streaming_api_url)
@@ -0,0 +1,151 @@
1
+ from typing import Literal, Iterator, Optional
2
+ from pathlib import Path
3
+
4
+ from google.protobuf.json_format import MessageToDict
5
+
6
+ from .base import BaseClient
7
+ from .models import (
8
+ ProcessItem,
9
+ ResultResponse,
10
+ StreamingOptions,
11
+ AudioUploadParams,
12
+ ProcessListParams,
13
+ ProcessListResponse,
14
+ StreamingResultResponse,
15
+ )
16
+ from .generated import api_pb2 as pb
17
+ from .generated import api_pb2_grpc as pb_grpc
18
+
19
+
20
+ class Behavioral(BaseClient):
21
+ def upload_audio(
22
+ self,
23
+ file_path: str,
24
+ name: Optional[str] = None,
25
+ embeddings: bool = False,
26
+ meta: Optional[str] = None,
27
+ ) -> ProcessItem:
28
+ """Uploads an audio file for processing and returns the process item.
29
+
30
+ Args:
31
+ file_path (str): Path to the audio file to upload.
32
+ name (str, optional): Optional name for the job request. Defaults to filename.
33
+ embeddings (bool): Whether to include speaker and behavioral embeddings. Defaults to False.
34
+ meta (str, optional): Metadata json containing any extra user-defined metadata.
35
+ Returns:
36
+ ProcessItem: The process item containing details about the submitted process.
37
+ """
38
+ # Create and validate parameters
39
+ params = AudioUploadParams(file_path=file_path, name=name, embeddings=embeddings, meta=meta)
40
+
41
+ # Use provided name or default to filename
42
+ job_name = params.name or Path(params.file_path).name
43
+
44
+ with open(params.file_path, "rb") as audio_file:
45
+ files = {"file": audio_file}
46
+ data = {"name": job_name, "embeddings": params.embeddings}
47
+
48
+ if params.meta:
49
+ data["meta"] = params.meta
50
+
51
+ data = self._send_request(
52
+ path=f"clients/{self.config.cid}/processes/audio",
53
+ method="POST",
54
+ files=files,
55
+ data=data,
56
+ )
57
+
58
+ return ProcessItem(**data)
59
+
60
+ def list_processes(
61
+ self,
62
+ page: int = 0,
63
+ page_size: int = 1000,
64
+ sort: Literal["asc", "desc"] = "asc",
65
+ start_date: Optional[str] = None,
66
+ end_date: Optional[str] = None,
67
+ ) -> ProcessListResponse:
68
+ """Lists all processes for the authenticated user.
69
+
70
+ Args:
71
+ page (int): Page number for pagination (default is 0).
72
+ page_size (int): Number of processes per page (default is 1000).
73
+ sort (str): Sort order for the processes, should be "asc" or "desc". Defaults to "asc".
74
+ start_date (str, optional: Filter processes created on or after this date (YYYY-MM-DD).
75
+ end_date (str, optional): Filter processes created on or before this date (YYYY-MM-DD).
76
+ Returns:
77
+ ProcessListResponse: A list of processes associated with the user.
78
+ """
79
+
80
+ query_params = ProcessListParams(
81
+ page=page, page_size=page_size, sort=sort, start_date=start_date, end_date=end_date
82
+ )
83
+ query_params = query_params.model_dump(by_alias=True, exclude_none=True)
84
+
85
+ data = self._send_request(
86
+ path=f"clients/{self.config.cid}/processes",
87
+ method="GET",
88
+ data=query_params,
89
+ )
90
+
91
+ return ProcessListResponse(processes=data)
92
+
93
+ def get_process(self, pid: int) -> ProcessItem:
94
+ """Retrieves details of a specific process by its ID.
95
+
96
+ Args:
97
+ pid (int): The process ID to retrieve.
98
+ Returns:
99
+ ProcessItem: The process item containing details about the specified process.
100
+ """
101
+
102
+ data = self._send_request(
103
+ path=f"clients/{self.config.cid}/processes/{pid}",
104
+ method="GET",
105
+ )
106
+
107
+ return ProcessItem(**data)
108
+
109
+ def get_result(self, pid: int) -> ResultResponse:
110
+ """Retrieves the result of a completed process by its ID.
111
+
112
+ Args:
113
+ pid (int): The process ID for which to retrieve the result
114
+ Returns:
115
+ ResultResponse: The result response containing the results of the specified process.
116
+ """
117
+ data = self._send_request(
118
+ path=f"clients/{self.config.cid}/processes/{pid}/results",
119
+ method="GET",
120
+ )
121
+ return ResultResponse(**data)
122
+
123
+ def stream_audio(
124
+ self, audio_stream: Iterator[bytes], options: StreamingOptions
125
+ ) -> Iterator[ResultResponse]:
126
+ with self._get_channel_context() as channel:
127
+ stub = pb_grpc.BehavioralStreamingApiStub(channel)
128
+
129
+ def _request_generator() -> Iterator[pb.AudioStream]:
130
+ # Streaming API always requires the first message to contain
131
+ # the audio configurationand authentication details
132
+ audio_config = options.to_pb_config()
133
+ req = pb.AudioStream(
134
+ cid=int(self.config.cid),
135
+ x_auth_token=self.config.api_key,
136
+ config=audio_config,
137
+ )
138
+ yield req
139
+
140
+ for chunk in audio_stream:
141
+ yield pb.AudioStream(
142
+ cid=int(self.config.cid),
143
+ x_auth_token=self.config.api_key,
144
+ audio_content=chunk,
145
+ )
146
+
147
+ response_stream = stub.StreamAudio(_request_generator())
148
+ for response in response_stream:
149
+ resp_dict = MessageToDict(response, always_print_fields_with_no_presence=True)
150
+ response_data = StreamingResultResponse(**resp_dict)
151
+ yield response_data
@@ -0,0 +1,22 @@
1
+ import importlib
2
+
3
+ from .base import BaseClient
4
+
5
+
6
+ client_map = {
7
+ "behavioral": ("behavioralsignals.behavioral", "Behavioral"),
8
+ "deepfakes": ("behavioralsignals.deepfakes", "Deepfakes"),
9
+ }
10
+
11
+
12
+ class Client(BaseClient):
13
+ def __getattr__(self, name):
14
+ if name in client_map:
15
+ module_path, class_name = client_map[name]
16
+ module = importlib.import_module(module_path)
17
+ client_class = getattr(module, class_name)
18
+ instance = client_class(cid=self.config.cid, api_key=self.config.api_key)
19
+ setattr(self, name, instance)
20
+ return instance
21
+
22
+ raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")
@@ -0,0 +1,24 @@
1
+ from typing import Union, Optional
2
+
3
+ from pydantic import field_validator
4
+ from pydantic.dataclasses import dataclass
5
+
6
+
7
+ TimeoutType = Union[float, tuple[float, float]]
8
+
9
+
10
+ @dataclass
11
+ class Configuration:
12
+ cid: Union[str, int]
13
+ api_key: str
14
+ api_url: str = "https://api.behavioralsignals.com/v5"
15
+ streaming_api_url: str = "streaming.behavioralsignals.com:443"
16
+ timeout: Optional[TimeoutType] = None
17
+ use_ssl: bool = True
18
+
19
+ @field_validator("cid", mode="before")
20
+ @classmethod
21
+ def convert_cid(cls, v):
22
+ if not isinstance(v, (str, int)):
23
+ raise TypeError(f"cid must be str or int, got {type(v).__name__}")
24
+ return str(v)
@@ -0,0 +1,151 @@
1
+ from typing import Literal, Iterator, Optional
2
+ from pathlib import Path
3
+
4
+ from google.protobuf.json_format import MessageToDict
5
+
6
+ from .base import BaseClient
7
+ from .models import (
8
+ ProcessItem,
9
+ ResultResponse,
10
+ StreamingOptions,
11
+ AudioUploadParams,
12
+ ProcessListParams,
13
+ ProcessListResponse,
14
+ StreamingResultResponse,
15
+ )
16
+ from .generated import api_pb2 as pb
17
+ from .generated import api_pb2_grpc as pb_grpc
18
+
19
+
20
+ class Deepfakes(BaseClient):
21
+ def upload_audio(
22
+ self,
23
+ file_path: str,
24
+ name: Optional[str] = None,
25
+ embeddings: bool = False,
26
+ meta: Optional[str] = None,
27
+ ) -> ProcessItem:
28
+ """Uploads an audio file for processing and returns the process item.
29
+
30
+ Args:
31
+ file_path (str): Path to the audio file to upload.
32
+ name (str, optional): Optional name for the job request. Defaults to filename.
33
+ embeddings (bool): Whether to include speaker and behavioral embeddings. Defaults to False.
34
+ meta (str, optional): Metadata json containing any extra user-defined metadata.
35
+ Returns:
36
+ ProcessItem: The process item containing details about the submitted process.
37
+ """
38
+ # Create and validate parameters
39
+ params = AudioUploadParams(file_path=file_path, name=name, embeddings=embeddings, meta=meta)
40
+
41
+ # Use provided name or default to filename
42
+ job_name = params.name or Path(params.file_path).name
43
+
44
+ with open(params.file_path, "rb") as audio_file:
45
+ files = {"file": audio_file}
46
+ data = {"name": job_name, "embeddings": params.embeddings}
47
+
48
+ if params.meta:
49
+ data["meta"] = params.meta
50
+
51
+ data = self._send_request(
52
+ path=f"detection/clients/{self.config.cid}/processes/audio",
53
+ method="POST",
54
+ files=files,
55
+ data=data,
56
+ )
57
+
58
+ return ProcessItem(**data)
59
+
60
+ def list_processes(
61
+ self,
62
+ page: int = 0,
63
+ page_size: int = 1000,
64
+ sort: Literal["asc", "desc"] = "asc",
65
+ start_date: Optional[str] = None,
66
+ end_date: Optional[str] = None,
67
+ ) -> ProcessListResponse:
68
+ """Lists all processes for the authenticated user.
69
+
70
+ Args:
71
+ page (int): Page number for pagination (default is 0).
72
+ page_size (int): Number of processes per page (default is 1000).
73
+ sort (str): Sort order for the processes, should be "asc" or "desc". Defaults to "asc".
74
+ start_date (str, optional: Filter processes created on or after this date (YYYY-MM-DD).
75
+ end_date (str, optional): Filter processes created on or before this date (YYYY-MM-DD).
76
+ Returns:
77
+ ProcessListResponse: A list of processes associated with the user.
78
+ """
79
+
80
+ query_params = ProcessListParams(
81
+ page=page, page_size=page_size, sort=sort, start_date=start_date, end_date=end_date
82
+ )
83
+ query_params = query_params.model_dump(by_alias=True, exclude_none=True)
84
+
85
+ data = self._send_request(
86
+ path=f"detection/clients/{self.config.cid}/processes",
87
+ method="GET",
88
+ data=query_params,
89
+ )
90
+
91
+ return ProcessListResponse(processes=data)
92
+
93
+ def get_process(self, pid: int) -> ProcessItem:
94
+ """Retrieves details of a specific process by its ID.
95
+
96
+ Args:
97
+ pid (int): The process ID to retrieve.
98
+ Returns:
99
+ ProcessItem: The process item containing details about the specified process.
100
+ """
101
+
102
+ data = self._send_request(
103
+ path=f"detection/clients/{self.config.cid}/processes/{pid}",
104
+ method="GET",
105
+ )
106
+
107
+ return ProcessItem(**data)
108
+
109
+ def get_result(self, pid: int) -> ResultResponse:
110
+ """Retrieves the result of a completed process by its ID.
111
+
112
+ Args:
113
+ pid (int): The process ID for which to retrieve the result
114
+ Returns:
115
+ ResultResponse: The result response containing the results of the specified process.
116
+ """
117
+ data = self._send_request(
118
+ path=f"detection/clients/{self.config.cid}/processes/{pid}/results",
119
+ method="GET",
120
+ )
121
+ return ResultResponse(**data)
122
+
123
+ def stream_audio(
124
+ self, audio_stream: Iterator[bytes], options: StreamingOptions
125
+ ) -> Iterator[ResultResponse]:
126
+ with self._get_channel_context() as channel:
127
+ stub = pb_grpc.BehavioralStreamingApiStub(channel)
128
+
129
+ def _request_generator() -> Iterator[pb.AudioStream]:
130
+ # Streaming API always requires the first message to contain
131
+ # the audio configurationand authentication details
132
+ audio_config = options.to_pb_config()
133
+ req = pb.AudioStream(
134
+ cid=int(self.config.cid),
135
+ x_auth_token=self.config.api_key,
136
+ config=audio_config,
137
+ )
138
+ yield req
139
+
140
+ for chunk in audio_stream:
141
+ yield pb.AudioStream(
142
+ cid=int(self.config.cid),
143
+ x_auth_token=self.config.api_key,
144
+ audio_content=chunk,
145
+ )
146
+
147
+ response_stream = stub.DeepfakeDetection(_request_generator())
148
+ for response in response_stream:
149
+ resp_dict = MessageToDict(response, always_print_fields_with_no_presence=True)
150
+ response_data = StreamingResultResponse(**resp_dict)
151
+ yield response_data
File without changes
@@ -0,0 +1,50 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: api.proto
5
+ # Protobuf Python Version: 6.31.0
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 6,
15
+ 31,
16
+ 0,
17
+ '',
18
+ 'api.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tapi.proto\x12\x16\x62\x65havioral_api.grpc.v1\"\xf4\x01\n\x0b\x41udioConfig\x12\x37\n\x08\x65ncoding\x18\x01 \x01(\x0e\x32%.behavioral_api.grpc.v1.AudioEncoding\x12\x19\n\x11sample_rate_hertz\x18\x02 \x01(\x05\x12\x31\n\x05level\x18\x03 \x01(\x0e\x32\x1d.behavioral_api.grpc.v1.LevelH\x00\x88\x01\x01\x12\x13\n\x06logits\x18\x04 \x01(\x08H\x01\x88\x01\x01\x12\x1e\n\x11\x66\x65\x61ture_embedding\x18\x05 \x01(\x08H\x02\x88\x01\x01\x42\x08\n\x06_levelB\t\n\x07_logitsB\x14\n\x12_feature_embedding\"|\n\x0b\x41udioStream\x12\x0b\n\x03\x63id\x18\x01 \x01(\x03\x12\x14\n\x0cx_auth_token\x18\x02 \x01(\t\x12\x33\n\x06\x63onfig\x18\x03 \x01(\x0b\x32#.behavioral_api.grpc.v1.AudioConfig\x12\x15\n\raudio_content\x18\x04 \x01(\x0c\"_\n\nPrediction\x12\r\n\x05label\x18\x01 \x01(\t\x12\x16\n\tposterior\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\x12\n\x05logit\x18\x03 \x01(\tH\x01\x88\x01\x01\x42\x0c\n\n_posteriorB\x08\n\x06_logit\"\x81\x02\n\x0fInferenceResult\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\nstart_time\x18\x02 \x01(\t\x12\x10\n\x08\x65nd_time\x18\x03 \x01(\t\x12\x0c\n\x04task\x18\x04 \x01(\t\x12\x36\n\nprediction\x18\x05 \x03(\x0b\x32\".behavioral_api.grpc.v1.Prediction\x12\x13\n\x0b\x66inal_label\x18\x06 \x01(\t\x12\x16\n\tembedding\x18\x07 \x01(\tH\x00\x88\x01\x01\x12\x31\n\x05level\x18\x08 \x01(\x0e\x32\x1d.behavioral_api.grpc.v1.LevelH\x01\x88\x01\x01\x42\x0c\n\n_embeddingB\x08\n\x06_level\"u\n\x0cStreamResult\x12\x0b\n\x03\x63id\x18\x01 \x01(\x03\x12\x0b\n\x03pid\x18\x02 \x01(\x03\x12\x12\n\nmessage_id\x18\x03 \x01(\x05\x12\x37\n\x06result\x18\x04 \x03(\x0b\x32\'.behavioral_api.grpc.v1.InferenceResult*\x1f\n\rAudioEncoding\x12\x0e\n\nLINEAR_PCM\x10\x00*#\n\x05Level\x12\x0b\n\x07segment\x10\x00\x12\r\n\tutterance\x10\x01\x32\xde\x01\n\x16\x42\x65havioralStreamingApi\x12^\n\x0bStreamAudio\x12#.behavioral_api.grpc.v1.AudioStream\x1a$.behavioral_api.grpc.v1.StreamResult\"\x00(\x01\x30\x01\x12\x64\n\x11\x44\x65\x65pfakeDetection\x12#.behavioral_api.grpc.v1.AudioStream\x1a$.behavioral_api.grpc.v1.StreamResult\"\x00(\x01\x30\x01\x62\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'api_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ DESCRIPTOR._loaded_options = None
34
+ _globals['_AUDIOENCODING']._serialized_start=886
35
+ _globals['_AUDIOENCODING']._serialized_end=917
36
+ _globals['_LEVEL']._serialized_start=919
37
+ _globals['_LEVEL']._serialized_end=954
38
+ _globals['_AUDIOCONFIG']._serialized_start=38
39
+ _globals['_AUDIOCONFIG']._serialized_end=282
40
+ _globals['_AUDIOSTREAM']._serialized_start=284
41
+ _globals['_AUDIOSTREAM']._serialized_end=408
42
+ _globals['_PREDICTION']._serialized_start=410
43
+ _globals['_PREDICTION']._serialized_end=505
44
+ _globals['_INFERENCERESULT']._serialized_start=508
45
+ _globals['_INFERENCERESULT']._serialized_end=765
46
+ _globals['_STREAMRESULT']._serialized_start=767
47
+ _globals['_STREAMRESULT']._serialized_end=884
48
+ _globals['_BEHAVIORALSTREAMINGAPI']._serialized_start=957
49
+ _globals['_BEHAVIORALSTREAMINGAPI']._serialized_end=1179
50
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,88 @@
1
+ from google.protobuf.internal import containers as _containers
2
+ from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
3
+ from google.protobuf import descriptor as _descriptor
4
+ from google.protobuf import message as _message
5
+ from collections.abc import Iterable as _Iterable, Mapping as _Mapping
6
+ from typing import ClassVar as _ClassVar, Optional as _Optional, Union as _Union
7
+
8
+ DESCRIPTOR: _descriptor.FileDescriptor
9
+
10
+ class AudioEncoding(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
11
+ __slots__ = ()
12
+ LINEAR_PCM: _ClassVar[AudioEncoding]
13
+
14
+ class Level(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
15
+ __slots__ = ()
16
+ segment: _ClassVar[Level]
17
+ utterance: _ClassVar[Level]
18
+ LINEAR_PCM: AudioEncoding
19
+ segment: Level
20
+ utterance: Level
21
+
22
+ class AudioConfig(_message.Message):
23
+ __slots__ = ("encoding", "sample_rate_hertz", "level", "logits", "feature_embedding")
24
+ ENCODING_FIELD_NUMBER: _ClassVar[int]
25
+ SAMPLE_RATE_HERTZ_FIELD_NUMBER: _ClassVar[int]
26
+ LEVEL_FIELD_NUMBER: _ClassVar[int]
27
+ LOGITS_FIELD_NUMBER: _ClassVar[int]
28
+ FEATURE_EMBEDDING_FIELD_NUMBER: _ClassVar[int]
29
+ encoding: AudioEncoding
30
+ sample_rate_hertz: int
31
+ level: Level
32
+ logits: bool
33
+ feature_embedding: bool
34
+ def __init__(self, encoding: _Optional[_Union[AudioEncoding, str]] = ..., sample_rate_hertz: _Optional[int] = ..., level: _Optional[_Union[Level, str]] = ..., logits: bool = ..., feature_embedding: bool = ...) -> None: ...
35
+
36
+ class AudioStream(_message.Message):
37
+ __slots__ = ("cid", "x_auth_token", "config", "audio_content")
38
+ CID_FIELD_NUMBER: _ClassVar[int]
39
+ X_AUTH_TOKEN_FIELD_NUMBER: _ClassVar[int]
40
+ CONFIG_FIELD_NUMBER: _ClassVar[int]
41
+ AUDIO_CONTENT_FIELD_NUMBER: _ClassVar[int]
42
+ cid: int
43
+ x_auth_token: str
44
+ config: AudioConfig
45
+ audio_content: bytes
46
+ def __init__(self, cid: _Optional[int] = ..., x_auth_token: _Optional[str] = ..., config: _Optional[_Union[AudioConfig, _Mapping]] = ..., audio_content: _Optional[bytes] = ...) -> None: ...
47
+
48
+ class Prediction(_message.Message):
49
+ __slots__ = ("label", "posterior", "logit")
50
+ LABEL_FIELD_NUMBER: _ClassVar[int]
51
+ POSTERIOR_FIELD_NUMBER: _ClassVar[int]
52
+ LOGIT_FIELD_NUMBER: _ClassVar[int]
53
+ label: str
54
+ posterior: str
55
+ logit: str
56
+ def __init__(self, label: _Optional[str] = ..., posterior: _Optional[str] = ..., logit: _Optional[str] = ...) -> None: ...
57
+
58
+ class InferenceResult(_message.Message):
59
+ __slots__ = ("id", "start_time", "end_time", "task", "prediction", "final_label", "embedding", "level")
60
+ ID_FIELD_NUMBER: _ClassVar[int]
61
+ START_TIME_FIELD_NUMBER: _ClassVar[int]
62
+ END_TIME_FIELD_NUMBER: _ClassVar[int]
63
+ TASK_FIELD_NUMBER: _ClassVar[int]
64
+ PREDICTION_FIELD_NUMBER: _ClassVar[int]
65
+ FINAL_LABEL_FIELD_NUMBER: _ClassVar[int]
66
+ EMBEDDING_FIELD_NUMBER: _ClassVar[int]
67
+ LEVEL_FIELD_NUMBER: _ClassVar[int]
68
+ id: str
69
+ start_time: str
70
+ end_time: str
71
+ task: str
72
+ prediction: _containers.RepeatedCompositeFieldContainer[Prediction]
73
+ final_label: str
74
+ embedding: str
75
+ level: Level
76
+ def __init__(self, id: _Optional[str] = ..., start_time: _Optional[str] = ..., end_time: _Optional[str] = ..., task: _Optional[str] = ..., prediction: _Optional[_Iterable[_Union[Prediction, _Mapping]]] = ..., final_label: _Optional[str] = ..., embedding: _Optional[str] = ..., level: _Optional[_Union[Level, str]] = ...) -> None: ...
77
+
78
+ class StreamResult(_message.Message):
79
+ __slots__ = ("cid", "pid", "message_id", "result")
80
+ CID_FIELD_NUMBER: _ClassVar[int]
81
+ PID_FIELD_NUMBER: _ClassVar[int]
82
+ MESSAGE_ID_FIELD_NUMBER: _ClassVar[int]
83
+ RESULT_FIELD_NUMBER: _ClassVar[int]
84
+ cid: int
85
+ pid: int
86
+ message_id: int
87
+ result: _containers.RepeatedCompositeFieldContainer[InferenceResult]
88
+ def __init__(self, cid: _Optional[int] = ..., pid: _Optional[int] = ..., message_id: _Optional[int] = ..., result: _Optional[_Iterable[_Union[InferenceResult, _Mapping]]] = ...) -> None: ...