API
API
This is used to communicate with the API.
- Register the device
- Post audio to the API
- Post video to the API
- [Optional] Queue speech to text
Source code in Client/Listener/api.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
__init__(domain=API_DOMAIN, token='', home_id=None, track_cluster=None)
The API class for the responder
It will require the token and the endpoint to communicate with the API.
If you deploy the API to a cloud server, do not forget to change the domain to the server's domain.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
domain
|
str
|
The domain of the API. |
API_DOMAIN
|
token
|
str
|
The token for the API. |
''
|
home_id
|
int
|
The home ID. |
None
|
track_cluster
|
str
|
The track cluster. |
None
|
Source code in Client/Listener/api.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
get_storage_solution()
Get the storage solution from the API Returns:
Source code in Client/Listener/api.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
|
post_audio(uid, sequence_index, audio_file, start_time, end_time, track_id=None)
Post metadata of the audio to the API. Args: uid (str): uuid of the audio sequence_index (int): The sequence index of the audio in this loop, together with uuid, it can be used to identify the audio audio_file (str): Path to the audio file, which will be synced to the API disk storage via another parameter start_time (datetime): The start time of the audio end_time (datetime): The end time of the audio track_id (str): The track id of the task
Returns:
Source code in Client/Listener/api.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
post_video(uid, video_file, start_time, end_time)
Post metadata of the video to the API. Args: uid (str): uuid of this video section video_file (str): Path to the video file, which will be synced to the API disk storage via another parameter it will also hold the information in the file name about the start/end time start_time (datetime): The start time of the video end_time (datetime): The end time of the video Returns:
Source code in Client/Listener/api.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
|
queue_speech_to_text(uid, audio_index, start_time, end_time)
Optional, used to queue the speech to text task Args: uid (str): uuid of the audio audio_index (str): The audio index, which can be used to identify the audio start_time (datetime): The start time of the audio end_time (datetime): The end time of the audio
Returns:
Type | Description |
---|---|
str
|
The track id of the task |
Source code in Client/Listener/api.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
register_device(device_name=None, device_type=None, description=None)
Register the device to the API. Args: device_name (Optional[str]): The device name, you can name it if you want to distinguish it better later device_type (Optional[str]): The device type, this can be used to distinguish the device type description (Optional[str]): The description of the device
Returns:
Source code in Client/Listener/api.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
upload_file(source_file, dest_path)
Upload the file to the API
Source code in Client/Listener/api.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|