...
資訊 |
---|
Open network access for app service ports (*.prod.ingress and *.stag.ingress) during deployment. |
目錄 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
Simply follow instruction in the README.
Connection URL:
Audio
...
+Image Mode:
URL:
wss://assistant-audio-prod.dvcbot.net/ws?vision=1&assistant_id=<ASSISTANT_ID>
Audio+Image Mode:
...
附註 |
---|
This link is for MTK's sandbox-production only. If you are a customer setting up DaVinci in your own environment, please contact SI or IT for this URL. Thank you. |
Specifying Subprotocols:
Subprotocols:
['proto', 'API_KEY']
Note. The client specifies one or more desired subprotocols by including the
Sec-WebSocket-Protocol
header in the handshake request.
...
Define message formats in a
.proto
file.Please refer to
of Davinci Voice Engine.View file name frames.proto
Compile your
.proto
file to get the generated source code.Include/import the generated source code with protocol buffer API to encode (serialize) and decode (deserialize) messages.
Example
Python
程式碼區塊 language py from protobuf import frames_pb2 from google.protobuf.json_format import MessageToJson # Encode (Serialize) fake_audio_data = b'\x00\x01\x02\x03' frame = frames_pb2.Frame() frame.audio.audio = fake_audio_data frame.audio.sample_rate = 16000 frame.audio.num_channels = 1 serialized_bystring = frame.SerializeToString() # Decode (deserialize) frame = frames_pb2.Frame() frame.ParseFromString(serialized_bystring) json_frame = MessageToJson(frame) ## Check the type of frame. if frame.HasField('audio'): pass elif frame.HasField('text'): pass
...
Decoding:
Determine the frame type by inspecting the first byte, and the frame length by inspecting the following bytes. (Refer to the illustration below)
AudioRawFrame
The whole frame
TextFrame
The whole frame
...
Encoding:
Must include the first few bytes indicating the frame type to the server.
AudioRawFrame
Bytestring starts from
b'\x12'
TextFrame
Bytestring starts from
b'\n'
...